GraphName { public static boolean isValidTopic(final String name) { boolean result = name != null; if (result) { final String topicName = GraphName.removeSheme(name); result = topicName != null && topicName.length() > 0 && topicName.matches("^(?!.*( !topicName.endsWith(PRIVATE) && !topicName.endsWith(SEPARATOR) ; if (result && topicName.startsWith(RELATIVE) && topicName.length() > 1) { result = topicName.startsWith(RELATIVE_TOPIC); } } return result; } private  GraphName(); static void addNode(final Node node); static void removeNode(final Node node); static void dispose(); static String getFullName(final String nameSpace, final String nodeName); static String getFullName(final Node node, final String name, final List<String> options); static boolean isValidTopic(final String name); static boolean isValidSubstitution(final String substitution); static boolean isValidFQDN(final String fqn);  }
@Test public final void testIsTopicName() { logger.debug(new Object(){}.getClass().getEnclosingMethod().getName()); Assert.assertFalse("Topic must not be null.", GraphName.isValidTopic(null)); Assert.assertFalse("Topic must not be empty.", GraphName.isValidTopic("")); Assert.assertTrue("Topic may contains valid charactere.", GraphName.isValidTopic("~/_foo")); Assert.assertTrue("Topic may contains valid charactere.", GraphName.isValidTopic("azertyuiopqsdfghjklmwxcvbn1234567890")); Assert.assertTrue("Topic may use balanced curly braces.", GraphName.isValidTopic("{bar}")); Assert.assertTrue("Topic may start with a tilde (~)", GraphName.isValidTopic("~/foo")); Assert.assertFalse("Topic may start with a tilde (~).", GraphName.isValidTopic("foo~")); Assert.assertFalse("Topic must not start with a numeric character ([0-9]).", GraphName.isValidTopic("8foo")); Assert.assertFalse("Topic must not contain any number of repeated underscores (_).", GraphName.isValidTopic("foo__bar")); Assert.assertFalse("Topic must not end with an underscore (_).", GraphName.isValidTopic("foo_")); Assert.assertFalse("Topic must not have an underscore (_) followed by a forward slash.", GraphName.isValidTopic("foo_/bar")); Assert.assertFalse("Topic must not end with a forward slash (/).", GraphName.isValidTopic("foo/bar/")); Assert.assertFalse("Topic must not contain any number of repeated forward slashes (/).", GraphName.isValidTopic("foo Assert.assertFalse("Topic must separate a tilde (~) from the rest of the name with a forward slash (/).", GraphName.isValidTopic("~foo")); Assert.assertTrue("Topic must have balanced curly braces ({}) when used.", GraphName.isValidTopic("~/foo")); Assert.assertTrue(GraphName.isValidTopic("foo")); Assert.assertTrue(GraphName.isValidTopic("abc123")); Assert.assertTrue(GraphName.isValidTopic("_foo")); Assert.assertTrue(GraphName.isValidTopic("Foo")); Assert.assertTrue(GraphName.isValidTopic("BAR")); Assert.assertTrue(GraphName.isValidTopic("~")); Assert.assertTrue(GraphName.isValidTopic("foo/bar")); Assert.assertTrue(GraphName.isValidTopic("~/foo")); Assert.assertTrue(GraphName.isValidTopic("{foo}_bar")); Assert.assertTrue(GraphName.isValidTopic("foo/{ping}/bar")); Assert.assertTrue(GraphName.isValidTopic(Topics.SCHEME + "/foo")); Assert.assertTrue(GraphName.isValidTopic(Topics.SCHEME + "foo/bar")); Assert.assertFalse(GraphName.isValidTopic("123abc")); Assert.assertFalse(GraphName.isValidTopic("123")); Assert.assertFalse(GraphName.isValidTopic("__foo")); Assert.assertFalse(GraphName.isValidTopic("foo__bar")); Assert.assertFalse(GraphName.isValidTopic("foo bar")); Assert.assertFalse(GraphName.isValidTopic("foo__")); Assert.assertFalse(GraphName.isValidTopic(" ")); Assert.assertFalse(GraphName.isValidTopic("foo_")); Assert.assertFalse(GraphName.isValidTopic("foo Assert.assertFalse(GraphName.isValidTopic("foo/")); Assert.assertFalse(GraphName.isValidTopic("foo_/bar ")); Assert.assertFalse(GraphName.isValidTopic("~foo")); Assert.assertFalse(GraphName.isValidTopic("foo~")); Assert.assertFalse(GraphName.isValidTopic("foo~/bar")); Assert.assertFalse(GraphName.isValidTopic("foo/~bar")); Assert.assertFalse(GraphName.isValidTopic("/_/bar")); Assert.assertFalse(GraphName.isValidTopic("_")); Assert.assertFalse(GraphName.isValidTopic("_/_bar")); Assert.assertFalse(GraphName.isValidTopic("/~")); Assert.assertFalse(GraphName.isValidTopic("foo/~/bar")); }