protected static void validate(final String name) {
        if (name.isEmpty())
            throw new TopologyException("Name is illegal, it can't be empty");
        if (name.equals(".") || name.equals(".."))
            throw new TopologyException("Name cannot be \".\" or \"..\"");
        if (name.length() > MAX_NAME_LENGTH)
            throw new TopologyException("Name is illegal, it can't be longer than " + MAX_NAME_LENGTH +
                    " characters, name: " + name);
        if (!containsValidPattern(name))
            throw new TopologyException("Name \"" + name + "\" is illegal, it contains a character other than " +
                    "ASCII alphanumerics, '.', '_' and '-'");
    }
@Test
    public void shouldThrowExceptionOnInvalidTopicNames() {
        final char[] longString = new char[250];
        Arrays.fill(longString, 'a');
        final String[] invalidNames = {"", "foo bar", "..", "foo:bar", "foo=bar", ".", new String(longString)};

        for (final String name : invalidNames) {
            try {
                Named.validate(name);
                fail("No exception was thrown for named with invalid name: " + name);
            } catch (final TopologyException e) {
                // success
            }
        }
    }