Package org.apache.accumulo.core.client.admin

Examples of org.apache.accumulo.core.client.admin.NamespaceOperations


  }

  @Test
  public void verifyNamespaceOperationsExceptions() throws Exception {
    IteratorSetting setting = new IteratorSetting(200, VersioningIterator.class);
    NamespaceOperations ops = c.namespaceOperations();

    // this one doesn't throw an exception, so don't fail; just check that it works
    assertFalse(ops.exists(namespace));

    // namespace operations that should throw a NamespaceNotFoundException
    int numRun = 0;
    NAMESPACENOTFOUND: for (int i = 0;; ++i)
      try {
        switch (i) {
          case 0:
            ops.addConstraint(namespace, NumericValueConstraint.class.getName());
            fail();
          case 1:
            ops.attachIterator(namespace, setting);
            fail();
          case 2:
            ops.checkIteratorConflicts(namespace, setting, EnumSet.of(IteratorScope.scan));
            fail();
          case 3:
            ops.delete(namespace);
            fail();
          case 4:
            ops.getIteratorSetting(namespace, "thing", IteratorScope.scan);
            fail();
          case 5:
            ops.getProperties(namespace);
            fail();
          case 6:
            ops.listConstraints(namespace);
            fail();
          case 7:
            ops.listIterators(namespace);
            fail();
          case 8:
            ops.removeConstraint(namespace, 1);
            fail();
          case 9:
            ops.removeIterator(namespace, "thing", EnumSet.allOf(IteratorScope.class));
            fail();
          case 10:
            ops.removeProperty(namespace, "a");
            fail();
          case 11:
            ops.rename(namespace, namespace + "2");
            fail();
          case 12:
            ops.setProperty(namespace, "k", "v");
            fail();
          case 13:
            ops.testClassLoad(namespace, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
            fail();
          default:
            // break out of infinite loop
            assertEquals(14, i); // check test integrity
            assertEquals(14, numRun); // check test integrity
            break NAMESPACENOTFOUND;
        }
      } catch (Exception e) {
        numRun++;
        if (!(e instanceof NamespaceNotFoundException))
          throw new Exception("Case " + i + " resulted in " + e.getClass().getName(), e);
      }

    // namespace operations that should throw a NamespaceExistsException
    numRun = 0;
    NAMESPACEEXISTS: for (int i = 0;; ++i)
      try {
        switch (i) {
          case 0:
            ops.create(namespace + "0");
            ops.create(namespace + "0"); // should fail here
            fail();
          case 1:
            ops.create(namespace + i + "_1");
            ops.create(namespace + i + "_2");
            ops.rename(namespace + i + "_1", namespace + i + "_2"); // should fail here
            fail();
          case 2:
            ops.create(Namespaces.DEFAULT_NAMESPACE);
            fail();
          case 3:
            ops.create(Namespaces.ACCUMULO_NAMESPACE);
            fail();
          case 4:
            ops.create(namespace + i + "_1");
            ops.rename(namespace + i + "_1", Namespaces.DEFAULT_NAMESPACE); // should fail here
            fail();
          case 5:
            ops.create(namespace + i + "_1");
            ops.rename(namespace + i + "_1", Namespaces.ACCUMULO_NAMESPACE); // should fail here
            fail();
          default:
            // break out of infinite loop
            assertEquals(6, i); // check test integrity
            assertEquals(6, numRun); // check test integrity
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.admin.NamespaceOperations

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.