Exemplo n.º 1
0
 @Test
 public void testDelete() throws FOMException, FluidException, JSONException, IOException {
   // Lets create a new namespace underneath the user's default root namespace
   Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername());
   String newName = UUID.randomUUID().toString();
   Namespace newNamespace = testNamespace.createNamespace(newName, "This is a test namespace");
   assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
   newNamespace.delete();
   testNamespace.getItem();
   assertEquals(false, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
 }
Exemplo n.º 2
0
 @Test
 public void testCreateNamespace()
     throws FOMException, FluidException, JSONException, IOException {
   // Lets create a new namespace underneath the user's default root namespace
   Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername());
   String newName = UUID.randomUUID().toString();
   Namespace newNamespace = testNamespace.createNamespace(newName, "This is a test namespace");
   assertEquals(newName, newNamespace.getName());
   assertEquals("This is a test namespace", newNamespace.getDescription());
   assertEquals(true, newNamespace.getId().length() > 0);
   assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
   newNamespace.delete();
   // Lets make sure validation works correctly...
   newName = "this is wrong"; // e.g. space is an invalid character
   String msg = "";
   try {
     newNamespace = testNamespace.createNamespace(newName, "This is a test namespace");
   } catch (FOMException ex) {
     msg = ex.getMessage();
   }
   assertEquals("Invalid name (incorrect characters or too long)", msg);
   // the new name is too long
   newName =
       "foobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspam";
   msg = "";
   try {
     newNamespace = testNamespace.createNamespace(newName, "This is a test namespace");
   } catch (FOMException ex) {
     msg = ex.getMessage();
   }
   assertEquals("Invalid name (incorrect characters or too long)", msg);
 }
Exemplo n.º 3
0
 @Test
 public void testGetNamespaceNames()
     throws FOMException, FluidException, JSONException, IOException {
   // Lets create a new namespace underneath the user's default root namespace
   Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername());
   String newName = UUID.randomUUID().toString();
   Namespace newNamespace = testNamespace.createNamespace(newName, "This is a test namespace");
   // check the change happens at FluidDB
   testNamespace.getItem();
   assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
   // delete the namespace
   newNamespace.delete();
   // this *won't* mean the namespace is removed from the local object
   assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
   // need to update from FluidDB
   testNamespace.getItem();
   assertEquals(false, TestUtils.contains(testNamespace.getNamespaceNames(), newName));
 }