Skip to content

Commit

Permalink
Add simple tests for query API
Browse files Browse the repository at this point in the history
  • Loading branch information
ghelmling committed Dec 21, 2009
1 parent cb64a54 commit 0757978
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 124 deletions.
2 changes: 0 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@
</fileset>
<fileset dir="${test.jysrc.dir}" id="tests.jython">
<include name="**/test_*.py" />
<!-- BUSTED: environment -->
<exclude name="**/test_query.py" />
</fileset>
</pathconvert>
</target>
Expand Down
106 changes: 66 additions & 40 deletions test/java/meetup/beeno/TestEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public static class SimpleEntity {
float floatProperty;
double doubleProperty;
long longProperty;

public SimpleEntity() {
}

public SimpleEntity(String id) {
this.id = id;
}

public SimpleEntity(String id,
String stringProp,
int intProp,
Expand All @@ -54,32 +54,42 @@ public SimpleEntity(String id,
this.doubleProperty = doubleProp;
this.longProperty = longProp;
}

@HRowKey
public String getId() { return this.id; }
public void setId(String id) { this.id = id; }

@HProperty(family="props", name="stringcol")
public String getStringProperty() { return stringProperty; }
public void setStringProperty( String stringProperty ) { this.stringProperty = stringProperty; }

public void setStringProperty( String stringProperty ) {
this.stringProperty = stringProperty;
}

@HProperty(family="props", name="intcol")
public int getIntProperty() { return intProperty; }
public void setIntProperty( int intProperty ) { this.intProperty = intProperty; }

public void setIntProperty( int intProperty ) {
this.intProperty = intProperty;
}

@HProperty(family="props", name="floatcol")
public float getFloatProperty() { return floatProperty; }
public void setFloatProperty( float floatProperty ) { this.floatProperty = floatProperty; }

public void setFloatProperty( float floatProperty ) {
this.floatProperty = floatProperty;
}

@HProperty(family="props", name="doublecol")
public double getDoubleProperty() { return doubleProperty; }
public void setDoubleProperty( double doubleProperty ) { this.doubleProperty = doubleProperty; }

public void setDoubleProperty( double doubleProperty ) {
this.doubleProperty = doubleProperty;
}

@HProperty(family="props", name="longcol")
public long getLongProperty() { return longProperty; }
public void setLongProperty( long longProperty ) { this.longProperty = longProperty; }
public void setLongProperty( long longProperty ) {
this.longProperty = longProperty;
}
}

/**
* More complex entity class containing mapped collections
* @author garyh
Expand All @@ -90,70 +100,74 @@ public static class ComplexEntity {
List<String> stringList = new ArrayList<String>();
Set<Integer> intSet = new HashSet<Integer>();
Map<String,String> extendedMap = new HashMap<String,String>();

public ComplexEntity() {}

public ComplexEntity(String id) {
this.id = id;
}

public ComplexEntity(String id, List<String> strings, Set<Integer> ints) {
this.id = id;
this.stringList = strings;
this.intSet = ints;
}

@HRowKey
public String getId() { return this.id; }
public void setId(String id) { this.id = id; }

@HProperty(family="props", name="strings", type="string")
public List<String> getStringList() { return this.stringList; }
public void setStringList(List<String> list) { this.stringList = list; }

@HProperty(family="props", name="ints", type="int_type")
public Set<Integer> getIntSet() { return this.intSet; }
public void setIntSet(Set<Integer> set) { this.intSet = set; }

@HProperty(family="extended", name="*", type="string")
public Map<String, String> getExtendedProps() { return this.extendedMap; }
public void setExtendedProps(Map<String,String> props) { this.extendedMap = props; }
public Map<String, String> getExtendedProps() {
return this.extendedMap;
}
public void setExtendedProps(Map<String,String> props) {
this.extendedMap = props;
}
}

@HBaseEntity(name="test_nokey")
public static class NoKeyEntity {
String prop1;

@HProperty(family="props", name="prop1")
public String getProp1() { return this.prop1; }
public void setProp1(String prop) { this.prop1 = prop; }
}

@HBaseEntity(name="test_dupekey")
public static class DupeKeyEntity {
String id1;
String id2;

@HRowKey
public String getId1() { return this.id1; }
@HRowKey
public String getId2() { return this.id2; }
}

@HBaseEntity(name="test_dupefield")
public static class DupeFieldEntity {
String id;
String prop1;
String prop2;

@HRowKey
public String getId() { return this.id; }
@HProperty(family="info", name="col1")
public String getProp1() { return this.prop1; }
@HProperty(family="info", name="col1")
public String getProp2() { return this.prop2; }
}

/**
* Simple, happy path entity with all the right annotations
* @author garyh
Expand All @@ -163,32 +177,44 @@ public static class DupeFieldEntity {
public static class IndexedEntity {
String id;
String stringProperty;
Integer intKey;
long timestamp;

public IndexedEntity() {
}

public IndexedEntity(String id) {
this.id = id;
}

public IndexedEntity(String id,
String stringProp,
long timestamp) {
String stringProp,
Integer intKey,
long timestamp) {
this.id = id;
this.stringProperty = stringProp;
this.intKey = intKey;
this.timestamp = timestamp;
}

@HRowKey
public String getId() { return this.id; }
public void setId(String id) { this.id = id; }

@HProperty(family="props", name="stringcol",
indexes = { @HIndex(extra_cols={"props:tscol"}) } )
public String getStringProperty() { return stringProperty; }
public void setStringProperty( String stringProperty ) { this.stringProperty = stringProperty; }

public void setStringProperty( String stringProperty ) {
this.stringProperty = stringProperty;
}

@HProperty(family="props", name="intcol",
indexes = { @HIndex(date_col="props:tscol", date_invert=true, extra_cols={"props:tscol"}) } )
public Integer getIntKey() { return intKey; }
public void setIntKey( Integer val ) {
this.intKey = val;
}

@HProperty(family="props", name="tscol")
public long getTimestamp() { return timestamp; }
public void setTimestamp( long ts ) { this.timestamp = ts; }
Expand Down
10 changes: 10 additions & 0 deletions test/jython/dbtest/hbase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from org.apache.hadoop.hbase import HBaseClusterTestCase

class HBaseContext(HBaseClusterTestCase):
def __init__(self):
super(HBaseContext, self).__init__()
self.setName('beeno')

if self.conf.get('test.build.data') is None:
self.conf.set('test.build.data', '/tmp/beeno')

10 changes: 1 addition & 9 deletions test/jython/dbtest/hbase/test_entity_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@

import java.lang
from java.util import ArrayList, HashSet, HashMap
from org.apache.hadoop.hbase import HBaseClusterTestCase
from org.apache.hadoop.hbase.client import HTablePool
from meetup.beeno import EntityMetadata, EntityService, HBaseException, MappingException
from meetup.beeno import TestEntities
from meetup.beeno.util import HUtil

class HBaseContext(HBaseClusterTestCase):
def __init__(self):
super(HBaseContext, self).__init__()
self.setName('beeno')

if self.conf.get('test.build.data') is None:
self.conf.set('test.build.data', '/tmp/beeno')
from dbtest.hbase import HBaseContext

hc = HBaseContext()

Expand Down
Loading

0 comments on commit 0757978

Please sign in to comment.