Search in sources :

Example 6 with CharacteristicWritable

use of org.apache.jena.hadoop.rdf.types.CharacteristicWritable in project jena by apache.

the class CharacteristicTests method checkCharacteristicSet.

/**
     * Checks a characteristic set
     * 
     * @param set
     *            Set
     * @param expectedItems
     *            Expected number of characteristics
     * @param expectedCounts
     *            Expected counts for characteristics
     */
protected final void checkCharacteristicSet(CharacteristicSetWritable set, int expectedItems, long[] expectedCounts) {
    Assert.assertEquals(expectedItems, set.size());
    Assert.assertEquals(expectedItems, expectedCounts.length);
    Iterator<CharacteristicWritable> iter = set.getCharacteristics();
    int i = 0;
    while (iter.hasNext()) {
        CharacteristicWritable cw = iter.next();
        Assert.assertEquals(expectedCounts[i], cw.getCount().get());
        i++;
    }
}
Also used : CharacteristicWritable(org.apache.jena.hadoop.rdf.types.CharacteristicWritable)

Example 7 with CharacteristicWritable

use of org.apache.jena.hadoop.rdf.types.CharacteristicWritable in project jena by apache.

the class CharacteristicTests method characteristic_set_writable_03.

/**
     * Tests characteristic sets
     * 
     * @throws IOException
     */
@Test
public void characteristic_set_writable_03() throws IOException {
    CharacteristicSetWritable set1 = new CharacteristicSetWritable();
    CharacteristicSetWritable set2 = new CharacteristicSetWritable();
    // Add some characteristics
    CharacteristicWritable cw1 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"));
    CharacteristicWritable cw2 = new CharacteristicWritable(NodeFactory.createURI("http://example.org/other"));
    set1.add(cw1);
    set2.add(cw2);
    this.checkCharacteristicSet(set1, 1, new long[] { 1 });
    this.checkCharacteristicSet(set2, 1, new long[] { 1 });
    this.checkRoundTrip(set1);
    this.checkRoundTrip(set2);
    Assert.assertNotEquals(set1, set2);
}
Also used : CharacteristicSetWritable(org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable) CharacteristicWritable(org.apache.jena.hadoop.rdf.types.CharacteristicWritable) Test(org.junit.Test)

Example 8 with CharacteristicWritable

use of org.apache.jena.hadoop.rdf.types.CharacteristicWritable in project jena by apache.

the class CharacteristicTests method characteristic_set_writable_02.

/**
     * Tests characteristic sets
     * 
     * @throws IOException
     */
@Test
public void characteristic_set_writable_02() throws IOException {
    CharacteristicSetWritable set = new CharacteristicSetWritable();
    // Add some characteristics
    CharacteristicWritable cw1 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"));
    CharacteristicWritable cw2 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"), 2);
    set.add(cw1);
    set.add(cw2);
    this.checkCharacteristicSet(set, 1, new long[] { 3 });
    this.checkRoundTrip(set);
}
Also used : CharacteristicSetWritable(org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable) CharacteristicWritable(org.apache.jena.hadoop.rdf.types.CharacteristicWritable) Test(org.junit.Test)

Example 9 with CharacteristicWritable

use of org.apache.jena.hadoop.rdf.types.CharacteristicWritable in project jena by apache.

the class CharacteristicTests method characteristic_writable_03.

/**
     * Tests characteristic properties
     * 
     * @throws IOException
     */
@Test
public void characteristic_writable_03() throws IOException {
    CharacteristicWritable cw1 = new CharacteristicWritable(NodeFactory.createURI("http://example.org"));
    CharacteristicWritable cw2 = new CharacteristicWritable(NodeFactory.createURI("http://example.org/other"));
    this.checkRoundTrip(cw1);
    this.checkRoundTrip(cw2);
    // Should not be equal as different nodes
    Assert.assertNotEquals(cw1, cw2);
}
Also used : CharacteristicWritable(org.apache.jena.hadoop.rdf.types.CharacteristicWritable) Test(org.junit.Test)

Example 10 with CharacteristicWritable

use of org.apache.jena.hadoop.rdf.types.CharacteristicWritable in project jena by apache.

the class CharacteristicTests method characteristic_writable_01.

/**
     * Tests characteristic round tripping
     * 
     * @throws IOException
     */
@Test
public void characteristic_writable_01() throws IOException {
    Node n = NodeFactory.createURI("http://example.org");
    CharacteristicWritable expected = new CharacteristicWritable(n);
    Assert.assertEquals(1, expected.getCount().get());
    this.checkRoundTrip(expected);
}
Also used : Node(org.apache.jena.graph.Node) CharacteristicWritable(org.apache.jena.hadoop.rdf.types.CharacteristicWritable) Test(org.junit.Test)

Aggregations

CharacteristicWritable (org.apache.jena.hadoop.rdf.types.CharacteristicWritable)10 Test (org.junit.Test)6 CharacteristicSetWritable (org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable)4 Node (org.apache.jena.graph.Node)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 NodeWritable (org.apache.jena.hadoop.rdf.types.NodeWritable)1