Beispiel #1
0
 @Test
 public void testGetSetDescription()
     throws FOMException, JSONException, FluidException, IOException {
   // We'll make use of the user's default root namespace (defined by their username)
   Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername());
   // Lets set the description
   testNamespace.setDescription("This is a test description");
   assertEquals("This is a test description", testNamespace.getDescription());
   // Lets get the same description from a newly instantiated object referencing the same
   // namespace so the description gets automagically pulled from FluidDB
   Namespace testNamespace2 = new Namespace(this.fdb, "", this.fdb.getUsername());
   assertEquals("This is a test description", testNamespace2.getDescription());
 }
Beispiel #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);
 }