Skip to content

Commit

Permalink
GORA-229 Use @ignore for unimplemented functionality to identify abse…
Browse files Browse the repository at this point in the history
…nt tests

git-svn-id: https://svn.apache.org/repos/asf/gora/trunk@1505236 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Lewis John McGibbney committed Jul 20, 2013
1 parent 87e64a5 commit 02cae63
Show file tree
Hide file tree
Showing 27 changed files with 395 additions and 366 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,8 @@

Gora Change Log

* GORA-229 Use @Ignore for unimplemented functionality to identify absent tests (Apostolos Giannakidis via lewismc)

* GORA-258 writeCapacUnits gets value from wrong attribute (Apostolos Giannakidis via lewismc)

* GORA-256 Add Solr store to gora-tutorial (Scott Stults via lewismc)
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.apache.gora.store.DataStoreFactory;
import org.apache.gora.store.DataStoreTestBase;
import org.apache.hadoop.conf.Configuration;
import org.junit.Ignore;

/**
*
Expand All @@ -45,8 +46,8 @@ protected DataStore<String,WebPage> createWebPageDataStore() throws IOException

//Until GORA-66 is resolved this test will always fail, so
//do not run it
@Ignore("skipped until GORA-66 is resolved")
@Override
public void testDeleteByQueryFields() throws IOException {
return;
}
}
Expand Up @@ -20,11 +20,11 @@
import java.io.DataOutputStream;
import java.io.IOException;

import junit.framework.Assert;

import org.apache.gora.accumulo.encoders.Encoder;
import org.apache.gora.accumulo.encoders.SignedBinaryEncoder;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
*
Expand All @@ -47,17 +47,17 @@ static long encl(long l) {

@Test
public void test1() {
Assert.assertEquals(encl(0x006f000000000000l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {0x00, 0x6f}));
Assert.assertEquals(encl(1l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {0, 0, 0, 0, 0, 0, 0, 0}));
Assert.assertEquals(encl(0x106f000000000001l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {0x10, 0x6f, 0, 0, 0, 0, 0, 0}));
Assert.assertEquals(
assertEquals(encl(0x006f000000000000l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {0x00, 0x6f}));
assertEquals(encl(1l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {0, 0, 0, 0, 0, 0, 0, 0}));
assertEquals(encl(0x106f000000000001l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {0x10, 0x6f, 0, 0, 0, 0, 0, 0}));
assertEquals(
encl(-1l),
(long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff,
(byte) 0xfe}));

Assert.assertEquals(encl(0x8000000000000001l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {(byte) 0x80, 0, 0, 0, 0, 0, 0, 0}));
Assert.assertEquals(
assertEquals(encl(0x8000000000000001l), (long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {(byte) 0x80, 0, 0, 0, 0, 0, 0, 0}));
assertEquals(
encl(0x8000000000000000l),
(long) AccumuloStore.followingKey(encoder, Long.class, new byte[] {(byte) 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff,
Expand All @@ -67,27 +67,27 @@ public void test1() {
try {
AccumuloStore.followingKey(encoder, Long.class,
new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff});
Assert.assertTrue(false);
assertTrue(false);
} catch (IllegalArgumentException iea) {

}
}

@Test
public void test2() {
Assert.assertEquals(encl(0x00ffffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {0x01}));
Assert.assertEquals(encl(0x006effffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {0x00, 0x6f}));
Assert.assertEquals(encl(0xff6effffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0xff, 0x6f}));
Assert.assertEquals(encl(0xfffeffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0xff, (byte) 0xff}));
Assert.assertEquals(encl(0l), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0, 0, 0, 0, 0, 0, 0, 0}));
assertEquals(encl(0x00ffffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {0x01}));
assertEquals(encl(0x006effffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {0x00, 0x6f}));
assertEquals(encl(0xff6effffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0xff, 0x6f}));
assertEquals(encl(0xfffeffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0xff, (byte) 0xff}));
assertEquals(encl(0l), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0, 0, 0, 0, 0, 0, 0, 0}));

Assert.assertEquals(encl(0x7effffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x7f}));
Assert.assertEquals(encl(0x7fffffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x80}));
Assert.assertEquals(encl(0x80ffffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x81}));
assertEquals(encl(0x7effffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x7f}));
assertEquals(encl(0x7fffffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x80}));
assertEquals(encl(0x80ffffffffffffffl), (long) AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0x81}));

try {
AccumuloStore.lastPossibleKey(encoder, Long.class, new byte[] {(byte) 0, 0, 0, 0, 0, 0, 0});
Assert.assertTrue(false);
assertTrue(false);
} catch (IllegalArgumentException iea) {

}
Expand Down
Expand Up @@ -17,7 +17,7 @@
package org.apache.gora.accumulo.util;

import org.apache.gora.accumulo.encoders.HexEncoder;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
Expand All @@ -29,12 +29,12 @@ public class HexEncoderTest {
public void testByte() {
HexEncoder encoder = new HexEncoder();

Assert.assertEquals("12", new String(encoder.encodeByte((byte) 0x12)));
Assert.assertEquals("f2", new String(encoder.encodeByte((byte) 0xf2)));
assertEquals("12", new String(encoder.encodeByte((byte) 0x12)));
assertEquals("f2", new String(encoder.encodeByte((byte) 0xf2)));

byte b = Byte.MIN_VALUE;
while (b != Byte.MAX_VALUE) {
Assert.assertEquals(b, encoder.decodeByte(encoder.encodeByte(b)));
assertEquals(b, encoder.decodeByte(encoder.encodeByte(b)));
b++;
}
}
Expand All @@ -43,12 +43,12 @@ public void testByte() {
public void testShort() {
HexEncoder encoder = new HexEncoder();

Assert.assertEquals("1234", new String(encoder.encodeShort((short) 0x1234)));
Assert.assertEquals("f234", new String(encoder.encodeShort((short) 0xf234)));
assertEquals("1234", new String(encoder.encodeShort((short) 0x1234)));
assertEquals("f234", new String(encoder.encodeShort((short) 0xf234)));

short s = Short.MIN_VALUE;
while (s != Short.MAX_VALUE) {
Assert.assertEquals(s, encoder.decodeShort(encoder.encodeShort(s)));
assertEquals(s, encoder.decodeShort(encoder.encodeShort(s)));
s++;
}
}
Expand Down
Expand Up @@ -19,11 +19,11 @@
import java.util.ArrayList;
import java.util.Collections;

import junit.framework.Assert;

import org.apache.gora.accumulo.encoders.SignedBinaryEncoder;
import org.apache.hadoop.io.Text;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
*
Expand All @@ -38,10 +38,10 @@ public void testShort() {

while (true) {
byte[] enc = encoder.encodeShort(s);
Assert.assertEquals(s, encoder.decodeShort(enc));
assertEquals(s, encoder.decodeShort(enc));
Text current = new Text(enc);
if (prev != null)
Assert.assertTrue(prev.compareTo(current) < 0);
assertTrue(prev.compareTo(current) < 0);
prev = current;
s++;
if (s == Short.MAX_VALUE)
Expand All @@ -57,10 +57,10 @@ private void testInt(int start, int finish) {

while (true) {
byte[] enc = encoder.encodeInt(i);
Assert.assertEquals(i, encoder.decodeInt(enc));
assertEquals(i, encoder.decodeInt(enc));
Text current = new Text(enc);
if (prev != null)
Assert.assertTrue(prev.compareTo(current) < 0);
assertTrue(prev.compareTo(current) < 0);
prev = current;
i++;
if (i == finish)
Expand All @@ -83,10 +83,10 @@ private void testLong(long start, long finish) {

while (true) {
byte[] enc = encoder.encodeLong(l);
Assert.assertEquals(l, encoder.decodeLong(enc));
assertEquals(l, encoder.decodeLong(enc));
Text current = new Text(enc);
if (prev != null)
Assert.assertTrue(prev.compareTo(current) < 0);
assertTrue(prev.compareTo(current) < 0);
prev = current;
l++;
if (l == finish)
Expand Down Expand Up @@ -124,9 +124,9 @@ public void testDouble() {

for (int i = 0; i < testData.size(); i++) {
byte[] enc = encoder.encodeDouble(testData.get(i));
Assert.assertEquals(testData.get(i), encoder.decodeDouble(enc));
assertEquals(testData.get(i), (Double) encoder.decodeDouble(enc));
if (i > 1) {
Assert.assertTrue("Checking " + testData.get(i) + " > " + testData.get(i - 1),
assertTrue("Checking " + testData.get(i) + " > " + testData.get(i - 1),
new Text(enc).compareTo(new Text(encoder.encodeDouble(testData.get(i - 1)))) > 0);
}
}
Expand Down Expand Up @@ -155,9 +155,9 @@ public void testFloat() {

for (int i = 0; i < testData.size(); i++) {
byte[] enc = encoder.encodeFloat(testData.get(i));
Assert.assertEquals(testData.get(i), encoder.decodeFloat(enc));
assertEquals(testData.get(i), (Float)encoder.decodeFloat(enc));
if (i > 1) {
Assert.assertTrue("Checking " + testData.get(i) + " > " + testData.get(i - 1),
assertTrue("Checking " + testData.get(i) + " > " + testData.get(i - 1),
new Text(enc).compareTo(new Text(encoder.encodeFloat(testData.get(i - 1)))) > 0);
}
}
Expand Down
Expand Up @@ -26,91 +26,102 @@
import java.io.IOException;

import org.apache.gora.cassandra.GoraCassandraTestDriver;
import org.apache.gora.cassandra.store.CassandraStore;
import org.apache.gora.examples.generated.Employee;
import org.apache.gora.examples.generated.WebPage;
import org.apache.gora.store.DataStore;
import org.apache.gora.store.DataStoreFactory;
import org.apache.gora.store.DataStoreTestBase;
import org.apache.hadoop.conf.Configuration;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;

/**
* Test for CassandraStore.
*/
public class TestCassandraStore extends DataStoreTestBase{

private Configuration conf;

static {
setTestDriver(new GoraCassandraTestDriver());
}

@Before
public void setUp() throws Exception {
super.setUp();
}

@SuppressWarnings("unchecked")
@Override
protected DataStore<String, Employee> createEmployeeDataStore() throws IOException {
return DataStoreFactory.getDataStore(CassandraStore.class, String.class, Employee.class, conf);
}

@SuppressWarnings("unchecked")
@Override
protected DataStore<String, WebPage> createWebPageDataStore() throws IOException {
return DataStoreFactory.getDataStore(CassandraStore.class, String.class, WebPage.class, conf);
}

public GoraCassandraTestDriver getTestDriver() {
return (GoraCassandraTestDriver) testDriver;
}


// ============================================================================
//We need to skip the following tests for a while until we fix some issues..

//We need to skip the following tests for a while until we fix some issues..

@Ignore("skipped until some bugs are fixed")
@Override
public void testGetWebPageDefaultFields() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testQuery() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testQueryStartKey() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testQueryEndKey() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testQueryKeyRange() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testQueryWebPageSingleKeyDefaultFields() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testDelete() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testDeleteByQuery() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testDeleteByQueryFields() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testGetPartitions() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testGetRecursive() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testGetDoubleRecursive() throws IOException{}
@Ignore("skipped until some bugs are fixed")
@Override
public void testGetNested() throws IOException {}
@Ignore("skipped until some bugs are fixed")
@Override
public void testGet3UnionField() throws IOException {}
// ============================================================================


public static void main(String[] args) throws Exception {
TestCassandraStore test = new TestCassandraStore();
test.setUpClass();
setUpClass();
test.setUp();

test.tearDown();
test.tearDownClass();
tearDownClass();
}

}
Expand Up @@ -182,4 +182,4 @@ public interface Persistent extends Cloneable{

Persistent clone();

}
}
Expand Up @@ -105,6 +105,7 @@ protected void setProperties(Properties properties) {
(Class<? extends DataStore<K,T>>)dataStoreClass, keyClass, persistentClass, conf);
dataStores.add(dataStore);

log.info("Datastore for "+persistentClass+" was added.");
return dataStore;
}

Expand Down
Expand Up @@ -20,15 +20,11 @@

import java.io.IOException;

import junit.framework.Assert;

import org.apache.avro.util.Utf8;
import org.apache.gora.avro.PersistentDatumReader;
import org.apache.gora.examples.WebPageDataCreator;
import org.apache.gora.examples.generated.Employee;
import org.apache.gora.examples.generated.WebPage;
import org.apache.gora.memory.store.MemStore;
import org.apache.gora.persistency.Persistent;
import org.apache.gora.persistency.impl.PersistentBase;
import org.apache.gora.query.Query;
import org.apache.gora.query.Result;
Expand All @@ -37,6 +33,8 @@
import org.apache.gora.store.DataStoreTestUtil;
import org.apache.hadoop.conf.Configuration;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;

/**
* Test case for {@link PersistentDatumReader}.
Expand All @@ -53,8 +51,8 @@ private void testClone(PersistentBase persistent) throws IOException {
}

private void assertClone(PersistentBase persistent, PersistentBase cloned) {
Assert.assertNotNull("cloned object is null", cloned);
Assert.assertEquals("cloned object is not equal to original object", persistent, cloned);
assertNotNull("cloned object is null", cloned);
assertEquals("cloned object is not equal to original object", persistent, cloned);
}

@Test
Expand Down Expand Up @@ -101,6 +99,6 @@ public void testCloneWebPage() throws Exception {
testClone(page);
tested++;
}
Assert.assertEquals(WebPageDataCreator.URLS.length, tested);
assertEquals(WebPageDataCreator.URLS.length, tested);
}
}

0 comments on commit 02cae63

Please sign in to comment.