Index: trunk/Nebulous-Server/t/03_server_create_object.t
===================================================================
--- trunk/Nebulous-Server/t/03_server_create_object.t	(revision 16205)
+++ trunk/Nebulous-Server/t/03_server_create_object.t	(revision 16221)
@@ -3,10 +3,10 @@
 # Copryight (C) 2004-2005  Joshua Hoblitt
 #
-# $Id: 03_server_create_object.t,v 1.20 2007-05-08 02:27:42 jhoblitt Exp $
+# $Id: 03_server_create_object.t,v 1.21 2008-01-25 01:53:28 jhoblitt Exp $
 
 use strict;
 use warnings FATAL => qw( all );
 
-use Test::More tests => 28;
+use Test::More tests => 64;
 
 use lib qw( ./t ./lib );
@@ -35,4 +35,56 @@
     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
+    uri_scheme_ok($uri, 'file');
+
+SKIP: {
+    skip "requires xattr support", 1 unless $test_xattr;
+    is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
+}
+}
+
+Test::Nebulous->setup;
+
+{
+    # key
+    my $uri = $neb->create_object("neb:/foo");
+
+    my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
+    ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
+    uri_scheme_ok($uri, 'file');
+
+SKIP: {
+    skip "requires xattr support", 1 unless $test_xattr;
+    is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
+}
+}
+
+Test::Nebulous->setup;
+
+{
+    # key
+    my $uri = $neb->create_object("neb://node01/foo");
+
+    my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
+    ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
+    uri_scheme_ok($uri, 'file');
+
+SKIP: {
+    skip "requires xattr support", 1 unless $test_xattr;
+    is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
+}
+}
+
+Test::Nebulous->setup;
+
+{
+    # key
+    my $uri = $neb->create_object("neb://node02/foo");
+
+    my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
+    ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
     uri_scheme_ok($uri, 'file');
 
@@ -51,4 +103,5 @@
     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
     uri_scheme_ok($uri, 'file');
 
@@ -60,4 +113,20 @@
 
 Test::Nebulous->setup;
+{
+    # key
+    my $uri = $neb->create_object("neb:///foo");
+
+    my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
+    ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
+    uri_scheme_ok($uri, 'file');
+
+SKIP: {
+    skip "requires xattr support", 1 unless $test_xattr;
+    is(getfattr($path, 'user.nebulous_key'), 'foo', 'user.nebulous_key xattr');
+}
+}
+
+Test::Nebulous->setup;
 
 {
@@ -67,4 +136,5 @@
     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
     uri_scheme_ok($uri, 'file');
 
@@ -79,8 +149,26 @@
 {
     # key
+    my $uri = $neb->create_object("neb:/foo/");
+
+    my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
+    ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
+    uri_scheme_ok($uri, 'file');
+
+SKIP: {
+    skip "requires xattr support", 1 unless $test_xattr;
+    is(getfattr($path, 'user.nebulous_key'), '/foo/', 'user.nebulous_key xattr');
+}
+}
+
+Test::Nebulous->setup;
+
+{
+    # key
     my $uri = $neb->create_object("foo/");
 
     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
     uri_scheme_ok($uri, 'file');
 
@@ -99,4 +187,5 @@
     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     ok(-e $path, "file exists");
+    ok($neb->find_instances("foo/bar"), 'object key exists');
     uri_scheme_ok($uri, 'file');
 
@@ -115,4 +204,5 @@
     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     ok(-e $path, "file exists");
+    ok($neb->find_instances("foo/bar"), 'object key exists');
     uri_scheme_ok($uri, 'file');
 
@@ -131,4 +221,17 @@
     my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
     ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
+    uri_scheme_ok($uri, 'file');
+}
+
+Test::Nebulous->setup;
+
+{
+    # volume name override
+    my $uri = $neb->create_object("neb://99/foo", "node01");
+
+    my ($scheme, $auth, $path, $query, $frag) = uri_split($uri);
+    ok(-e $path, "file exists");
+    ok($neb->find_instances("foo"), 'object key exists');
     uri_scheme_ok($uri, 'file');
 }
@@ -145,4 +248,12 @@
 
 eval {
+    $neb->create_object("neb:/foo");
+    $neb->create_object("neb:/foo");
+};
+like($@, qr/Duplicate entry/, "object already exists");
+
+Test::Nebulous->setup;
+
+eval {
     $neb->create_object("foo", 'node03');
 };
@@ -152,4 +263,11 @@
 
 eval {
+    $neb->create_object("neb://node03/foo");
+};
+like($@, qr/node03 is not available/, "request volume this is full");
+
+Test::Nebulous->setup;
+
+eval {
     $neb->create_object("foo", 'node04');
 };
@@ -159,4 +277,11 @@
 
 eval {
+    $neb->create_object("neb://node04/foo");
+};
+like($@, qr/node04 is not available/, "request volume with allocate = FALSE, available = FALSE");
+
+Test::Nebulous->setup;
+
+eval {
     $neb->create_object("foo", 'node05');
 };
@@ -166,4 +291,11 @@
 
 eval {
+    $neb->create_object("neb://node05/foo");
+};
+like($@, qr/node05 is not available/, "request volume with allocate = FALSE , available = TRUE");
+
+Test::Nebulous->setup;
+
+eval {
     $neb->create_object("foo", 'node06');
 };
@@ -173,4 +305,11 @@
 
 eval {
+    $neb->create_object("neb://node06/foo");
+};
+like($@, qr/node06 is not available/, "request volume with allocate = TRUE, available = FALSE");
+
+Test::Nebulous->setup;
+
+eval {
     $neb->create_object("foo", 99);
 };
@@ -180,4 +319,11 @@
 
 eval {
+    $neb->create_object("neb://99/foo");
+};
+like($@, qr/is not available/, "volume name doesn't exist");
+
+Test::Nebulous->setup;
+
+eval {
     $neb->create_object();
 };
