Skip to content
Browse files

Upgrade tests to junit 4 so that sbt will run them.

  • Loading branch information...
1 parent bc3d880 commit c60c65731eb0eba54bddeeea77e785fb031ad9f4 @stephenh committed Dec 7, 2010
View
3 ivy.xml
@@ -19,6 +19,7 @@
<dependency org="org.mortbay.jetty" name="jetty" rev="6.1.19" conf="buildtime->default;test->default;sources->sources"/>
<dependency org="com.google.code.typica" name="typica" rev="1.5.2a" conf="test->default;sources->sources"/>
- <dependency org="junit" name="junit" rev="3.8.1" conf="test->default;sources->sources"/>
+ <dependency org="junit" name="junit" rev="4.8.2" conf="test->default;sources->sources"/>
+ <dependency org="com.novocode" name="junit-interface" rev="0.4.0" conf="test->default;sources->sources"/>
</dependencies>
</ivy-module>
View
11 ivysettings.xml
@@ -0,0 +1,11 @@
+<ivysettings>
+ <settings defaultResolver="default"/>
+ <include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
+ <resolvers>
+ <ibiblio name="bryanjswift" m2compatible="true" root="http://repos.bryanjswift.com/maven2/"/>
+ <chain name="default">
+ <resolver ref="bryanjswift"/>
+ <resolver ref="public"/>
+ </chain>
+ </resolvers>
+</ivysettings>
View
7 src/test/scala/fakesdb/AbstractFakeSdbTest.scala
@@ -1,17 +1,18 @@
package fakesdb
-import junit.framework.TestCase
+import org.junit._
import com.xerox.amazonws.sdb.ItemAttribute
import com.xerox.amazonws.sdb.SimpleDB
-abstract class AbstractFakeSdbTest extends TestCase {
+abstract class AbstractFakeSdbTest {
// typica does not respect ports 9999
// val sdb = new SimpleDB(System.getenv("AWS_ACCESS_KEY_ID"), System.getenv("AWS_SECRET_ACCESS_KEY"), false)
val sdb = new SimpleDB("ignored", "ignored", false, "127.0.0.1")
val domaina = sdb.getDomain("domaina")
- override def setUp(): Unit = {
+ @Before
+ def setUp(): Unit = {
flush()
}
View
8 src/test/scala/fakesdb/BatchPutAttributesTest.scala
@@ -1,15 +1,17 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
import com.xerox.amazonws.sdb.ItemAttribute
class BatchPutAttributesTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- flush()
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}
+ @Test
def testPut(): Unit = {
val as = new java.util.ArrayList[ItemAttribute]()
as.add(new ItemAttribute("a", "1", true))
View
10 src/test/scala/fakesdb/DeleteAttributesTest.scala
@@ -1,15 +1,17 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
import com.xerox.amazonws.sdb.ItemAttribute
class DeleteAttributesTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- flush()
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}
+ @Test
def testDeleteOneEntireAttribute(): Unit = {
add(domaina, "itema", "a" -> "1", "b" -> "2")
@@ -25,6 +27,7 @@ class DeleteAttributesTest extends AbstractFakeSdbTest {
assertEquals("b", now.get(0).getName)
}
+ @Test
def testDeleteBothAttributesDeletesTheItem(): Unit = {
add(domaina, "itema", "a" -> "1", "b" -> "2")
@@ -39,6 +42,7 @@ class DeleteAttributesTest extends AbstractFakeSdbTest {
assertEquals(0, domaina.listItems.getItemList.size)
}
+ @Test
def testDeleteNoAttributesDeletesTheItem(): Unit = {
add(domaina, "itema", "a" -> "1", "b" -> "2")
View
8 src/test/scala/fakesdb/DomainMetadataTest.scala
@@ -1,14 +1,16 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
class DomainMetadataTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- super.setUp
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}
+ @Test
def testFoo(): Unit = {
add(domaina, "itema", "aa" -> "111", "bb" -> "222", "bb" -> "333")
View
2 src/test/scala/fakesdb/ErrorTest.scala
@@ -1,6 +1,6 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit.Assert._
import com.xerox.amazonws.sdb.ItemAttribute
import com.xerox.amazonws.sdb.SimpleDB
View
4 src/test/scala/fakesdb/FlushDomainsTest.scala
@@ -1,9 +1,11 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
class FlushDomainsTest extends AbstractFakeSdbTest {
+ @Test
def testFoo(): Unit = {
// Start with a flush
sdb.createDomain("_flush")
View
10 src/test/scala/fakesdb/GetAttributesTest.scala
@@ -1,14 +1,16 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
class GetAttributesTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- super.setUp
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}
+ @Test
def testGetMultipleValues(): Unit = {
add(domaina, "itema", "a" -> "1", "a" -> "2", "b" -> "3")
val attrs = domaina.getItem("itema").getAttributes
@@ -21,6 +23,7 @@ class GetAttributesTest extends AbstractFakeSdbTest {
assertEquals("3", attrs.get(2).getValue)
}
+ @Test
def testGetOneAttribute(): Unit = {
add(domaina, "itema",
"a" -> "1",
@@ -35,6 +38,7 @@ class GetAttributesTest extends AbstractFakeSdbTest {
assertEquals("1", attrs.get(0).getValue)
}
+ @Test
def testGetAttributesDoesNotCreateAnItem(): Unit = {
val attrs = domaina.getItem("itema").getAttributes
assertEquals(0, attrs.size)
View
4 src/test/scala/fakesdb/ListDomainsTest.scala
@@ -1,9 +1,11 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
class ListDomainsTest extends AbstractFakeSdbTest {
+ @Test
def testFoo(): Unit = {
sdb.createDomain("domain1")
sdb.createDomain("domain2")
View
9 src/test/scala/fakesdb/PutAttributesTest.scala
@@ -1,14 +1,16 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
class PutAttributesTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- super.setUp
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}
+ @Test
def testPutOne(): Unit = {
add(domaina, "itema", "a" -> "1")
val attrs = domaina.getItem("itema").getAttributes
@@ -17,6 +19,7 @@ class PutAttributesTest extends AbstractFakeSdbTest {
assertEquals("1", attrs.get(0).getValue)
}
+ @Test
def testPutMultipleValues(): Unit = {
add(domaina, "itema", "a" -> "1", "a" -> "2")
val attrs = domaina.getItem("itema").getAttributes
View
34 src/test/scala/fakesdb/QueryParserTest.scala
@@ -1,18 +1,20 @@
package fakesdb
-import junit.framework.TestCase
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
-class QueryParserTest extends TestCase {
+class QueryParserTest {
var item: Item = null
var item2: Item = null
- override def setUp(): Unit = {
+ @Before
+ def setUp(): Unit = {
item = new Item("item1")
item2 = new Item("item2")
}
+ @Test
def testEquals(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' = 'value1']")
item.put("attribute1", "value1", true)
@@ -22,6 +24,7 @@ class QueryParserTest extends TestCase {
assertNotIn(qe,item)
}
+ @Test
def testNotEquals(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' != 'value1']")
// No attribute1 at all means false
@@ -34,6 +37,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testLessThan(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' < '001']")
// No attribute1 at all means false
@@ -46,6 +50,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testGreaterThan(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' > '001']")
// No attribute1 at all means false
@@ -58,6 +63,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testLessThanOrEqualTo(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' <= '001']")
// No attribute1 at all means false
@@ -70,6 +76,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testGreaterThanOrEqualTo(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' >= '001']")
// No attribute1 at all means false
@@ -82,6 +89,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testStartsWith(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' starts-with 'a']")
// No attribute1 at all means false
@@ -94,6 +102,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testDoesNotStartWith(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' does-not-start-with 'a']")
// No attribute1 at all means false
@@ -106,6 +115,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testAnd(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' > '1' and 'attribute1' < '5']")
// No attribute1 or attribute2 at all means false
@@ -118,6 +128,7 @@ class QueryParserTest extends TestCase {
assertNotIn(qe, item)
}
+ @Test
def testAndNamesMustMatch(): Unit = {
try {
val qe = QueryParser.makeQueryEval("['attribute1' = 'value1' and 'attribute2' = 'value2']")
@@ -128,6 +139,7 @@ class QueryParserTest extends TestCase {
}
}
+ @Test
def testOr(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' < '5' or 'attribute1' > '7']")
// No attribute1 means false
@@ -140,6 +152,7 @@ class QueryParserTest extends TestCase {
assertNotIn(qe, item)
}
+ @Test
def testNot(): Unit = {
val qe = QueryParser.makeQueryEval("not ['attribute1' = 'value1']")
// No attribute1 at all matches
@@ -152,6 +165,7 @@ class QueryParserTest extends TestCase {
assertNotIn(qe, item)
}
+ @Test
def testCrazyAnd(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' = 'value1' and 'attribute1' = 'value2']")
item.put("attribute1", "value1", true)
@@ -160,6 +174,7 @@ class QueryParserTest extends TestCase {
assertNotIn(qe, item)
}
+ @Test
def testIntersection(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' = 'value1'] intersection ['attribute2' = 'value2']")
item.put("attribute1", "value1", true)
@@ -169,13 +184,15 @@ class QueryParserTest extends TestCase {
assertNotIn(qe, item2)
}
+ @Test
def testIntersection2(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' = 'value2'] intersection ['attribute2' >= 'value2'] sort 'attribute2'")
item.put("attribute1", "value1", true)
item.put("attribute2", "value2", true)
assertNotIn(qe, item)
}
+ @Test
def testPrecendence(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' = 'value1'] intersection ['attribute2' = 'value2'] union ['attribute3' = 'value3']")
// could be ((a && b) || c) <-- this one is right
@@ -186,6 +203,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item)
}
+ @Test
def testNotBindsBeforeIntersection(): Unit = {
val qe = QueryParser.makeQueryEval("not ['attribute1' = 'value1'] intersection ['attribute2' = 'value2']")
item.put("attribute1", "value1", true)
@@ -196,6 +214,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item2)
}
+ @Test
def testUnion(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' = 'value1'] union ['attribute2' = 'value2']")
item.put("attribute1", "value1", true)
@@ -204,6 +223,7 @@ class QueryParserTest extends TestCase {
assertIn(qe, item2)
}
+ @Test
def testSort(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' > '0'] sort 'attribute1'")
item.put("attribute1", "2", true)
@@ -215,6 +235,7 @@ class QueryParserTest extends TestCase {
assertEquals(item, sorted(1))
}
+ @Test
def testSortDesc(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' > '0'] sort 'attribute1' desc")
item.put("attribute1", "1", true)
@@ -226,6 +247,7 @@ class QueryParserTest extends TestCase {
assertEquals(item, sorted(1))
}
+ @Test
def testSortAsc(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' > '0'] sort 'attribute1' asc")
item.put("attribute1", "2", true)
@@ -237,6 +259,7 @@ class QueryParserTest extends TestCase {
assertEquals(item, sorted(1))
}
+ @Test
def testSortIntersection(): Unit = {
val qe = QueryParser.makeQueryEval("['attribute1' > '0'] intersection ['attribute2' > '0'] sort 'attribute1' asc")
item.put("attribute1", "2", true)
@@ -250,6 +273,7 @@ class QueryParserTest extends TestCase {
assertEquals(item, sorted(1))
}
+ @Test
def testSortFailedIfOtherNonQueriedAttribute(): Unit = {
try {
val qe = QueryParser.makeQueryEval("['attribute1' > '0'] sort 'attribute2'")
@@ -260,6 +284,7 @@ class QueryParserTest extends TestCase {
}
}
+ @Test
def testSortFailedIfQueriedAttributeWasNegated(): Unit = {
try {
val qe = QueryParser.makeQueryEval("not ['attribute1' > '0'] sort 'attribute1'")
@@ -270,6 +295,7 @@ class QueryParserTest extends TestCase {
}
}
+ @Test
def testKeyWithUnderscores(): Unit = {
val qe = QueryParser.makeQueryEval("['foo_bar' = 'value1']")
item.put("foo_bar", "value1", true)
View
11 src/test/scala/fakesdb/QueryTest.scala
@@ -1,20 +1,23 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
import com.xerox.amazonws.sdb.ItemAttribute
class QueryTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- super.setUp
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}
+ @Test
def testEmptyQuery(): Unit = {
val results = domaina.listItems
assertEquals(0, results.getItemList.size)
}
+ @Test
def testEverythingQuery(): Unit = {
add(domaina, "itema", "a" -> "b")
add(domaina, "itemb", "a" -> "c")
@@ -24,6 +27,7 @@ class QueryTest extends AbstractFakeSdbTest {
assertEquals("itemb", results.getItemList.get(1).getIdentifier)
}
+ @Test
def testAnd(): Unit = {
add(domaina, "itema", "a" -> "1")
add(domaina, "itemb", "a" -> "4")
@@ -32,6 +36,7 @@ class QueryTest extends AbstractFakeSdbTest {
assertEquals("itema", results.getItemList.get(0).getIdentifier)
}
+ @Test
def testSort(): Unit = {
add(domaina, "itema", "a" -> "2")
add(domaina, "itemb", "a" -> "1")
View
13 src/test/scala/fakesdb/QueryWithAttributesTest.scala
@@ -1,20 +1,23 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
import com.xerox.amazonws.sdb.ItemAttribute
class QueryWithAttributesTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- super.setUp
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}
+ @Test
def testEmpty(): Unit = {
val results = domaina.listItemsWithAttributes(null, null, null, 0)
assertEquals(0, results.getItems.size)
}
+ @Test
def testEverything(): Unit = {
add(domaina, "itema", "a" -> "1", "b" -> "2")
add(domaina, "itemb", "a" -> "3")
@@ -28,6 +31,7 @@ class QueryWithAttributesTest extends AbstractFakeSdbTest {
assertEquals("3", results.getItems.get("itemb").get(0).getValue)
}
+ @Test
def testQueryOneWithAllAttributes(): Unit = {
add(domaina, "itema", "a" -> "1", "b" -> "2")
add(domaina, "itemb", "a" -> "3")
@@ -39,6 +43,7 @@ class QueryWithAttributesTest extends AbstractFakeSdbTest {
assertEquals("2", results.getItems.get("itema").get(1).getValue)
}
+ @Test
def testQueryOneWithSomeAttributes(): Unit = {
add(domaina, "itema", "a" -> "1", "b" -> "2")
add(domaina, "itemb", "a" -> "3")
@@ -51,6 +56,7 @@ class QueryWithAttributesTest extends AbstractFakeSdbTest {
assertEquals("2", results.getItems.get("itema").get(0).getValue)
}
+ @Test
def testQueryOneWithNoneOfTheAttributes(): Unit = {
add(domaina, "itema", "a" -> "1", "b" -> "2")
add(domaina, "itemb", "a" -> "1") // both meet the where clause
@@ -63,6 +69,7 @@ class QueryWithAttributesTest extends AbstractFakeSdbTest {
assertEquals("2", results.getItems.get("itema").get(0).getValue)
}
+ @Test
def testSort(): Unit = {
add(domaina, "itema", "a" -> "2")
add(domaina, "itemb", "a" -> "1")
View
42 src/test/scala/fakesdb/SelectParserTest.scala
@@ -1,23 +1,26 @@
package fakesdb
-import junit.framework.Assert._
-import junit.framework.TestCase
+import org.junit._
+import org.junit.Assert._
-class SelectParserTest extends TestCase {
+class SelectParserTest {
val data = new Data
var domaina: Domain = null
- override def setUp(): Unit = {
+ @Before
+ def setUp(): Unit = {
data.flush
domaina = data.getOrCreateDomain("domaina")
}
+ @Test
def testEmptyFrom(): Unit = {
val se = SelectParser.makeSelectEval("select * from domaina")
assertEquals(0, se.select(data).size)
}
+ @Test
def testFromWithData(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("b", "2", true)
@@ -28,6 +31,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("c", "3"))), results(1))
}
+ @Test
def testFromWithOneAttribute(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("b", "2", true)
@@ -43,6 +47,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("b", "2"))), results2(0))
}
+ @Test
def testFromWithOneAttributeWithMultipleValues(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("a", "1", false)
@@ -51,6 +56,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"), ("a", "1"))), results(0))
}
+ @Test
def testFromWithTwoAttributes(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("b", "2", true)
@@ -61,27 +67,31 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "3"))), results(1))
}
+ @Test
def testFromCount(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
val results = SelectParser.makeSelectEval("select count(*) from domaina").select(data)
assertEquals(1, results.size)
assertEquals(("Domain", List(("Count", "1"))), results(0))
}
+ @Test
def testFromCountUpperCase(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
val results = SelectParser.makeSelectEval("SELECT COUNT(*) FROM domaina").select(data)
assertEquals(1, results.size)
assertEquals(("Domain", List(("Count", "1"))), results(0))
}
+ @Test
def testFromItemName(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
val results = SelectParser.makeSelectEval("select itemName(), a from domaina").select(data)
assertEquals(1, results.size)
assertEquals(("itema", List(("itemName()", "itema"), ("a", "1"))), results(0))
}
+ @Test
def testWhereEquals(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -90,6 +100,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"))), results(0))
}
+ @Test
def testWhereNotEquals(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -98,6 +109,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(0))
}
+ @Test
def testWhereGreaterThan(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -106,6 +118,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(0))
}
+ @Test
def testWhereLessThan(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -114,6 +127,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"))), results(0))
}
+ @Test
def testWhereGreaterThanOrEqual(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -124,6 +138,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemc", List(("a", "3"))), results(1))
}
+ @Test
def testWhereLessThanOrEqual(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -134,6 +149,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(1))
}
+ @Test
def testWhereLike(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -142,6 +158,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"))), results(0))
}
+ @Test
def testWhereNotLike(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -150,6 +167,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(0))
}
+ @Test
def testWhereIsNull(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("b", "2", true)
@@ -158,6 +176,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("b", "2"))), results(0))
}
+ @Test
def testWhereIsNotNull(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("b", "2", true)
@@ -166,6 +185,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"))), results(0))
}
+ @Test
def testWhereBetween(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -174,6 +194,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(0))
}
+ @Test
def testWhereEvery(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("a", "1", false)
@@ -184,6 +205,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"), ("a", "1"))), results(0))
}
+ @Test
def testWhereIn(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -194,6 +216,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(1))
}
+ @Test
def testWhereEqualsAnd(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("b", "2", true)
@@ -203,6 +226,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"), ("b", "2"))), results(0))
}
+ @Test
def testWhereEqualsOr(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -212,6 +236,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(1))
}
+ @Test
def testWhereParens(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("b", "1", true)
@@ -222,6 +247,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itemb", List(("a", "2"))), results(1))
}
+ @Test
def testOrderBy(): Unit = {
domaina.getOrCreateItem("itema").put("a", "2", true)
domaina.getOrCreateItem("itemb").put("a", "1", true)
@@ -231,6 +257,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "2"))), results(1))
}
+ @Test
def testOrderByDesc(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -240,6 +267,7 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"))), results(1))
}
+ @Test
def testOrderByItemNameDesc(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itemb").put("a", "2", true)
@@ -251,13 +279,15 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"))), results(2))
}
+ @Test
def testWhereCrazyAnd(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("a", "2", false)
val results = SelectParser.makeSelectEval("select * from domaina where a = '1' and a = '2'").select(data)
assertEquals(1, results.size) // FAIL
}
+ @Test
def testWhereIntersection(): Unit = {
domaina.getOrCreateItem("itema").put("a", "1", true)
domaina.getOrCreateItem("itema").put("a", "2", false)
@@ -267,20 +297,23 @@ class SelectParserTest extends TestCase {
assertEquals(("itema", List(("a", "1"), ("a", "2"))), results(0))
}
+ @Test
def testKeyWithUnderscores(): Unit = {
domaina.getOrCreateItem("itema").put("foo_bar", "1", true)
val results = SelectParser.makeSelectEval("select * from domaina where foo_bar = '1'").select(data)
assertEquals(1, results.size)
assertEquals(("itema", List(("foo_bar", "1"))), results(0))
}
+ @Test
def testCaseInsensitiveKeywords(): Unit = {
domaina.getOrCreateItem("itema").put("foo_bar", "1", true)
val results = SelectParser.makeSelectEval("SELECT * FROM domaina WHERE foo_bar = '1'").select(data)
assertEquals(1, results.size)
assertEquals(("itema", List(("foo_bar", "1"))), results(0))
}
+ @Test
def testLarrysQuery(): Unit = {
val usage = data.getOrCreateDomain("dev.api-web-usage")
val a = usage.getOrCreateItem("itema")
@@ -290,6 +323,7 @@ class SelectParserTest extends TestCase {
assertEquals(1, results.size)
}
+ @Test
def testLimit(): Unit = {
domaina.getOrCreateItem("itema").put("foo", "1", true)
domaina.getOrCreateItem("itemb").put("foo", "2", true)
View
7 src/test/scala/fakesdb/SelectTest.scala
@@ -1,12 +1,13 @@
package fakesdb
-import junit.framework.Assert._
+import org.junit._
+import org.junit.Assert._
import com.xerox.amazonws.sdb._
class SelectTest extends AbstractFakeSdbTest {
- override def setUp(): Unit = {
- super.setUp
+ @Before
+ def createDomain(): Unit = {
sdb.createDomain("domaina")
}

0 comments on commit c60c657

Please sign in to comment.
Something went wrong with that request. Please try again.