@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); }
/** * Tests create Namespace. Also tests the getters. * * @throws Exception to JUnit. */ public void testCreateNamespace() throws Exception { URL file = new URL("http://localhost"); Namespace ns = new Namespace("ns", file, "format", 5, null); assertTrue(ns.getName().equals("ns")); assertTrue(ns.getFile() == file); assertTrue(ns.getFormat().equals("format")); assertTrue(ns.getExceptionLevel() == 5); assertNull(ns.getProperties()); ConfigProperties cp = prepareProperties(); ns.setProperties(cp); assertTrue(ns.getProperties() == cp); try { ns.setProperties(null); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { } }
@Override public void visitNamespace(Namespace ns) { visit(ns.getName()); visitDeclarations(ns); }