File: serializer-rdfjson.t

package info (click to toggle)
librdf-trine-perl 1.015-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,188 kB
  • ctags: 1,059
  • sloc: perl: 17,584; makefile: 30; sql: 20
file content (39 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use Test::More tests => 3;

use strict;
use warnings;
no warnings 'redefine';

use RDF::Trine;
use_ok('RDF::Trine::Serializer::RDFJSON');

my $model = RDF::Trine::Model->new(RDF::Trine::Store->temporary_store);

$model->add_hashref({
	'http://example.com/doc' => {
		'http://example.com/predicate' => [
				{
					'type' => 'literal',
					'value' => 'Foo',
				},
				{
					'type' => 'uri',
					'value' => 'http://example.com/bar',
				},
				'baz@en'
			],
		},
	});

ok($model->count_statements(
		RDF::Trine::Node::Resource->new('http://example.com/doc'),
		RDF::Trine::Node::Resource->new('http://example.com/predicate'),
		RDF::Trine::Node::Literal->new('baz', 'en'),
		),
	"add_hashref works");

my $serializer = RDF::Trine::Serializer::RDFJSON->new();	
my $json = $serializer->serialize_model_to_string($model);

ok($json =~ /^\{/, "RDF/JSON serialiser seems to work");