Repository: accumulo
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 8f5728084 -> f51d7bba0


http://git-wip-us.apache.org/repos/asf/accumulo/blob/382bfdce/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
 
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
index 3654440..b1afa43 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/OutputConfigurator.java
@@ -16,40 +16,39 @@
  */
 package org.apache.accumulo.core.client.mapreduce.lib.util;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
 import org.apache.hadoop.conf.Configuration;
 
 /**
+ * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
  * @since 1.5.0
  */
+@Deprecated
 public class OutputConfigurator extends ConfiguratorBase {
-  
+
   /**
    * Configuration keys for {@link BatchWriter}.
    * 
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    */
+  @Deprecated
   public static enum WriteOpts {
     DEFAULT_TABLE_NAME, BATCH_WRITER_CONFIG
   }
-  
+
   /**
    * Configuration keys for various features.
    * 
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    */
+  @Deprecated
   public static enum Features {
     CAN_CREATE_TABLES, SIMULATION_MODE
   }
-  
+
   /**
    * Sets the default table name to use if one emits a null in place of a 
table name for a given mutation. Table names can only be alpha-numeric and
    * underscores.
@@ -60,13 +59,14 @@ public class OutputConfigurator extends ConfiguratorBase {
    *          the Hadoop configuration object to configure
    * @param tableName
    *          the table to use when the tablename is null in the write call
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    */
+  @Deprecated
   public static void setDefaultTableName(Class<?> implementingClass, 
Configuration conf, String tableName) {
-    if (tableName != null)
-      conf.set(enumToConfKey(implementingClass, WriteOpts.DEFAULT_TABLE_NAME), 
tableName);
+    
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setDefaultTableName(implementingClass,
 conf, tableName);
   }
-  
+
   /**
    * Gets the default table name from the configuration.
    * 
@@ -75,13 +75,15 @@ public class OutputConfigurator extends ConfiguratorBase {
    * @param conf
    *          the Hadoop configuration object to configure
    * @return the default table name
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    * @see #setDefaultTableName(Class, Configuration, String)
    */
+  @Deprecated
   public static String getDefaultTableName(Class<?> implementingClass, 
Configuration conf) {
-    return conf.get(enumToConfKey(implementingClass, 
WriteOpts.DEFAULT_TABLE_NAME));
+    return 
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.getDefaultTableName(implementingClass,
 conf);
   }
-  
+
   /**
    * Sets the configuration for for the job's {@link BatchWriter} instances. 
If not set, a new {@link BatchWriterConfig}, with sensible built-in defaults is
    * used. Setting the configuration multiple times overwrites any previous 
configuration.
@@ -92,21 +94,14 @@ public class OutputConfigurator extends ConfiguratorBase {
    *          the Hadoop configuration object to configure
    * @param bwConfig
    *          the configuration for the {@link BatchWriter}
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    */
+  @Deprecated
   public static void setBatchWriterOptions(Class<?> implementingClass, 
Configuration conf, BatchWriterConfig bwConfig) {
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    String serialized;
-    try {
-      bwConfig.write(new DataOutputStream(baos));
-      serialized = new String(baos.toByteArray(), Constants.UTF8);
-      baos.close();
-    } catch (IOException e) {
-      throw new IllegalArgumentException("unable to serialize " + 
BatchWriterConfig.class.getName());
-    }
-    conf.set(enumToConfKey(implementingClass, WriteOpts.BATCH_WRITER_CONFIG), 
serialized);
+    
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setBatchWriterOptions(implementingClass,
 conf, bwConfig);
   }
-  
+
   /**
    * Gets the {@link BatchWriterConfig} settings.
    * 
@@ -115,26 +110,15 @@ public class OutputConfigurator extends ConfiguratorBase {
    * @param conf
    *          the Hadoop configuration object to configure
    * @return the configuration object
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    * @see #setBatchWriterOptions(Class, Configuration, BatchWriterConfig)
    */
+  @Deprecated
   public static BatchWriterConfig getBatchWriterOptions(Class<?> 
implementingClass, Configuration conf) {
-    String serialized = conf.get(enumToConfKey(implementingClass, 
WriteOpts.BATCH_WRITER_CONFIG));
-    BatchWriterConfig bwConfig = new BatchWriterConfig();
-    if (serialized == null || serialized.isEmpty()) {
-      return bwConfig;
-    } else {
-      try {
-        ByteArrayInputStream bais = new 
ByteArrayInputStream(serialized.getBytes(Constants.UTF8));
-        bwConfig.readFields(new DataInputStream(bais));
-        bais.close();
-        return bwConfig;
-      } catch (IOException e) {
-        throw new IllegalArgumentException("unable to serialize " + 
BatchWriterConfig.class.getName());
-      }
-    }
+    return 
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.getBatchWriterOptions(implementingClass,
 conf);
   }
-  
+
   /**
    * Sets the directive to create new tables, as necessary. Table names can 
only be alpha-numeric and underscores.
    * 
@@ -147,12 +131,14 @@ public class OutputConfigurator extends ConfiguratorBase {
    *          the Hadoop configuration object to configure
    * @param enableFeature
    *          the feature is enabled if true, disabled otherwise
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    */
+  @Deprecated
   public static void setCreateTables(Class<?> implementingClass, Configuration 
conf, boolean enableFeature) {
-    conf.setBoolean(enumToConfKey(implementingClass, 
Features.CAN_CREATE_TABLES), enableFeature);
+    
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setCreateTables(implementingClass,
 conf, enableFeature);
   }
-  
+
   /**
    * Determines whether tables are permitted to be created as needed.
    * 
@@ -161,13 +147,15 @@ public class OutputConfigurator extends ConfiguratorBase {
    * @param conf
    *          the Hadoop configuration object to configure
    * @return true if the feature is disabled, false otherwise
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    * @see #setCreateTables(Class, Configuration, boolean)
    */
+  @Deprecated
   public static Boolean canCreateTables(Class<?> implementingClass, 
Configuration conf) {
-    return conf.getBoolean(enumToConfKey(implementingClass, 
Features.CAN_CREATE_TABLES), false);
+    return 
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.canCreateTables(implementingClass,
 conf);
   }
-  
+
   /**
    * Sets the directive to use simulation mode for this job. In simulation 
mode, no output is produced. This is useful for testing.
    * 
@@ -180,12 +168,14 @@ public class OutputConfigurator extends ConfiguratorBase {
    *          the Hadoop configuration object to configure
    * @param enableFeature
    *          the feature is enabled if true, disabled otherwise
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    */
+  @Deprecated
   public static void setSimulationMode(Class<?> implementingClass, 
Configuration conf, boolean enableFeature) {
-    conf.setBoolean(enumToConfKey(implementingClass, 
Features.SIMULATION_MODE), enableFeature);
+    
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.setSimulationMode(implementingClass,
 conf, enableFeature);
   }
-  
+
   /**
    * Determines whether this feature is enabled.
    * 
@@ -194,11 +184,13 @@ public class OutputConfigurator extends ConfiguratorBase {
    * @param conf
    *          the Hadoop configuration object to configure
    * @return true if the feature is enabled, false otherwise
+   * @deprecated since 1.6.0; Configure your job with the appropriate 
InputFormat or OutputFormat.
    * @since 1.5.0
    * @see #setSimulationMode(Class, Configuration, boolean)
    */
+  @Deprecated
   public static Boolean getSimulationMode(Class<?> implementingClass, 
Configuration conf) {
-    return conf.getBoolean(enumToConfKey(implementingClass, 
Features.SIMULATION_MODE), false);
+    return 
org.apache.accumulo.core.client.mapreduce.lib.impl.OutputConfigurator.getSimulationMode(implementingClass,
 conf);
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/382bfdce/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
 
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
index 013cb79..53bda87 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/util/package-info.java
@@ -15,20 +15,7 @@
  * limitations under the License.
  */
 /**
- * This package exists to store common helpers for configuring MapReduce jobs 
in a single location. It contains static configurator methods, stored in classes
- * separate from the things they configure (typically, {@link 
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat}/
- * {@link org.apache.accumulo.core.client.mapreduce.AccumuloOutputFormat} and 
related classes in compatible frameworks), rather than storing them in those
- * InputFormats/OutputFormats, so as not to clutter their API with methods 
that don't match the conventions for that framework. These classes may be 
useful to
- * input/output plugins for other frameworks, so they can reuse the same 
configuration options and/or serialize them into a
- * {@link org.apache.hadoop.conf.Configuration} instance in a standard way.
- * 
- * <p>
- * It is not expected these will change much (except when new features are 
added), but end users should not use these classes. They should use the static
- * configurators on the {@link org.apache.hadoop.mapreduce.InputFormat} or 
{@link org.apache.hadoop.mapreduce.OutputFormat} they are configuring, which in 
turn
- * may use these classes to implement their own static configurators. Once 
again, these classes are intended for internal use, but may be useful to 
developers
- * of plugins for other frameworks that read/write to Accumulo.
- * 
+ * @deprecated since 1.6.0; This package was moved out of the public API.
  * @since 1.5.0
  */
 package org.apache.accumulo.core.client.mapreduce.lib.util;
-

http://git-wip-us.apache.org/repos/asf/accumulo/blob/382bfdce/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java
 
b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java
new file mode 100644
index 0000000..1983470
--- /dev/null
+++ 
b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/impl/ConfiguratorBaseTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.client.mapreduce.lib.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.ClientConfiguration;
+import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.ZooKeeperInstance;
+import org.apache.accumulo.core.client.mock.MockInstance;
+import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
+import 
org.apache.accumulo.core.client.security.tokens.AuthenticationToken.AuthenticationTokenSerializer;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class ConfiguratorBaseTest {
+
+  private static enum PrivateTestingEnum {
+    SOMETHING, SOMETHING_ELSE
+  }
+
+  @Test
+  public void testEnumToConfKey() {
+    assertEquals(this.getClass().getSimpleName() + 
".PrivateTestingEnum.Something",
+        ConfiguratorBase.enumToConfKey(this.getClass(), 
PrivateTestingEnum.SOMETHING));
+    assertEquals(this.getClass().getSimpleName() + 
".PrivateTestingEnum.SomethingElse",
+        ConfiguratorBase.enumToConfKey(this.getClass(), 
PrivateTestingEnum.SOMETHING_ELSE));
+  }
+
+  @Test
+  public void 
testSetConnectorInfoClassOfQConfigurationStringAuthenticationToken() throws 
AccumuloSecurityException {
+    Configuration conf = new Configuration();
+    assertFalse(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
+    ConfiguratorBase.setConnectorInfo(this.getClass(), conf, "testUser", new 
PasswordToken("testPassword"));
+    assertTrue(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
+    assertEquals("testUser", ConfiguratorBase.getPrincipal(this.getClass(), 
conf));
+    AuthenticationToken token = 
ConfiguratorBase.getAuthenticationToken(this.getClass(), conf);
+    assertEquals(PasswordToken.class, token.getClass());
+    assertEquals(new PasswordToken("testPassword"), token);
+    assertEquals(
+        "inline:" + PasswordToken.class.getName() + ":" + 
Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(new 
PasswordToken("testPassword"))),
+        conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.ConnectorInfo.TOKEN)));
+  }
+
+  @Test
+  public void testSetConnectorInfoClassOfQConfigurationStringString() throws 
AccumuloSecurityException {
+    Configuration conf = new Configuration();
+    assertFalse(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
+    ConfiguratorBase.setConnectorInfo(this.getClass(), conf, "testUser", 
"testFile");
+    assertTrue(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
+    assertEquals("testUser", ConfiguratorBase.getPrincipal(this.getClass(), 
conf));
+    assertEquals("file:testFile", 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.ConnectorInfo.TOKEN)));
+  }
+
+  @Test
+  public void testSetZooKeeperInstance() {
+    Configuration conf = new Configuration();
+    ConfiguratorBase.setZooKeeperInstance(this.getClass(), conf, new 
ClientConfiguration().withInstance("testInstanceName").withZkHosts("testZooKeepers")
+        .withSsl(true).withZkTimeout(1234));
+    ClientConfiguration clientConf = 
ClientConfiguration.deserialize(conf.get(ConfiguratorBase.enumToConfKey(this.getClass(),
+        ConfiguratorBase.InstanceOpts.CLIENT_CONFIG)));
+    assertEquals("testInstanceName", 
clientConf.get(ClientProperty.INSTANCE_NAME));
+    assertEquals("testZooKeepers", 
clientConf.get(ClientProperty.INSTANCE_ZK_HOST));
+    assertEquals("true", 
clientConf.get(ClientProperty.INSTANCE_RPC_SSL_ENABLED));
+    assertEquals("1234", clientConf.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
+    assertEquals(ZooKeeperInstance.class.getSimpleName(), 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.TYPE)));
+
+    Instance instance = ConfiguratorBase.getInstance(this.getClass(), conf);
+    assertEquals(ZooKeeperInstance.class.getName(), 
instance.getClass().getName());
+    assertEquals("testInstanceName", ((ZooKeeperInstance) 
instance).getInstanceName());
+    assertEquals("testZooKeepers", ((ZooKeeperInstance) 
instance).getZooKeepers());
+    assertEquals(1234000, ((ZooKeeperInstance) 
instance).getZooKeepersSessionTimeOut());
+  }
+
+  @Test
+  public void testSetMockInstance() {
+    Configuration conf = new Configuration();
+    ConfiguratorBase.setMockInstance(this.getClass(), conf, 
"testInstanceName");
+    assertEquals("testInstanceName", 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.NAME)));
+    assertEquals(null, 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.ZOO_KEEPERS)));
+    assertEquals(MockInstance.class.getSimpleName(), 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.TYPE)));
+    Instance instance = ConfiguratorBase.getInstance(this.getClass(), conf);
+    assertEquals(MockInstance.class.getName(), instance.getClass().getName());
+  }
+
+  @Test
+  public void testSetLogLevel() {
+    Configuration conf = new Configuration();
+    Level currentLevel = Logger.getLogger(this.getClass()).getLevel();
+
+    ConfiguratorBase.setLogLevel(this.getClass(), conf, Level.DEBUG);
+    Logger.getLogger(this.getClass()).setLevel(currentLevel);
+    assertEquals(Level.DEBUG, ConfiguratorBase.getLogLevel(this.getClass(), 
conf));
+
+    ConfiguratorBase.setLogLevel(this.getClass(), conf, Level.INFO);
+    Logger.getLogger(this.getClass()).setLevel(currentLevel);
+    assertEquals(Level.INFO, ConfiguratorBase.getLogLevel(this.getClass(), 
conf));
+
+    ConfiguratorBase.setLogLevel(this.getClass(), conf, Level.FATAL);
+    Logger.getLogger(this.getClass()).setLevel(currentLevel);
+    assertEquals(Level.FATAL, ConfiguratorBase.getLogLevel(this.getClass(), 
conf));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/382bfdce/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBaseTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBaseTest.java
 
b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBaseTest.java
deleted file mode 100644
index 3b5143f..0000000
--- 
a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/lib/util/ConfiguratorBaseTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.core.client.mapreduce.lib.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.ClientConfiguration;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.ZooKeeperInstance;
-import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
-import org.apache.accumulo.core.client.mock.MockInstance;
-import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
-import 
org.apache.accumulo.core.client.security.tokens.AuthenticationToken.AuthenticationTokenSerializer;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.junit.Test;
-
-/**
- * 
- */
-public class ConfiguratorBaseTest {
-
-  private static enum PrivateTestingEnum {
-    SOMETHING, SOMETHING_ELSE
-  }
-
-  @Test
-  public void testEnumToConfKey() {
-    assertEquals(this.getClass().getSimpleName() + 
".PrivateTestingEnum.Something",
-        ConfiguratorBase.enumToConfKey(this.getClass(), 
PrivateTestingEnum.SOMETHING));
-    assertEquals(this.getClass().getSimpleName() + 
".PrivateTestingEnum.SomethingElse",
-        ConfiguratorBase.enumToConfKey(this.getClass(), 
PrivateTestingEnum.SOMETHING_ELSE));
-  }
-
-  @Test
-  public void 
testSetConnectorInfoClassOfQConfigurationStringAuthenticationToken() throws 
AccumuloSecurityException {
-    Configuration conf = new Configuration();
-    assertFalse(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
-    ConfiguratorBase.setConnectorInfo(this.getClass(), conf, "testUser", new 
PasswordToken("testPassword"));
-    assertTrue(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
-    assertEquals("testUser", ConfiguratorBase.getPrincipal(this.getClass(), 
conf));
-    AuthenticationToken token = 
ConfiguratorBase.getAuthenticationToken(this.getClass(), conf);
-    assertEquals(PasswordToken.class, token.getClass());
-    assertEquals(new PasswordToken("testPassword"), token);
-    assertEquals(
-        "inline:" + PasswordToken.class.getName() + ":" + 
Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(new 
PasswordToken("testPassword"))),
-        conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.ConnectorInfo.TOKEN)));
-  }
-
-  @Test
-  public void testSetConnectorInfoClassOfQConfigurationStringString() throws 
AccumuloSecurityException {
-    Configuration conf = new Configuration();
-    assertFalse(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
-    ConfiguratorBase.setConnectorInfo(this.getClass(), conf, "testUser", 
"testFile");
-    assertTrue(ConfiguratorBase.isConnectorInfoSet(this.getClass(), conf));
-    assertEquals("testUser", ConfiguratorBase.getPrincipal(this.getClass(), 
conf));
-    assertEquals("file:testFile", 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.ConnectorInfo.TOKEN)));
-  }
-
-  @SuppressWarnings("deprecation")
-  @Test
-  public void testSetZooKeeperInstance_legacy() {
-    Configuration conf = new Configuration();
-    ConfiguratorBase.setZooKeeperInstance(this.getClass(), conf, 
"testInstanceName", "testZooKeepers");
-    ClientConfiguration clientConf = 
ClientConfiguration.deserialize(conf.get(ConfiguratorBase.enumToConfKey(this.getClass(),
 ConfiguratorBase.InstanceOpts.CLIENT_CONFIG)));
-    assertEquals("testInstanceName", 
clientConf.get(ClientProperty.INSTANCE_NAME));
-    assertEquals("testZooKeepers", 
clientConf.get(ClientProperty.INSTANCE_ZK_HOST));
-    assertEquals(ZooKeeperInstance.class.getSimpleName(), 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.TYPE)));
-
-    Instance instance = ConfiguratorBase.getInstance(this.getClass(), conf);
-    assertEquals(ZooKeeperInstance.class.getName(), 
instance.getClass().getName());
-    assertEquals("testInstanceName", 
((ZooKeeperInstance)instance).getInstanceName());
-    assertEquals("testZooKeepers", 
((ZooKeeperInstance)instance).getZooKeepers());
-
-    // Also make sure we can still deserialize job configurations with the old 
keys
-    conf = new Configuration();
-    conf.set(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.TYPE), ZooKeeperInstance.class.getSimpleName());
-    conf.set(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.NAME), "testInstanceName");
-    conf.set(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.ZOO_KEEPERS), "testZooKeepers");
-    instance = ConfiguratorBase.getInstance(this.getClass(), conf);
-    assertEquals("testInstanceName", 
((ZooKeeperInstance)instance).getInstanceName());
-    assertEquals("testZooKeepers", 
((ZooKeeperInstance)instance).getZooKeepers());
-  }
-
-  @Test
-  public void testSetZooKeeperInstance() {
-    Configuration conf = new Configuration();
-    ConfiguratorBase.setZooKeeperInstance(this.getClass(), conf, new 
ClientConfiguration().withInstance("testInstanceName").withZkHosts("testZooKeepers").withSsl(true).withZkTimeout(1234));
-    ClientConfiguration clientConf = 
ClientConfiguration.deserialize(conf.get(ConfiguratorBase.enumToConfKey(this.getClass(),
 ConfiguratorBase.InstanceOpts.CLIENT_CONFIG)));
-    assertEquals("testInstanceName", 
clientConf.get(ClientProperty.INSTANCE_NAME));
-    assertEquals("testZooKeepers", 
clientConf.get(ClientProperty.INSTANCE_ZK_HOST));
-    assertEquals("true", 
clientConf.get(ClientProperty.INSTANCE_RPC_SSL_ENABLED));
-    assertEquals("1234", clientConf.get(ClientProperty.INSTANCE_ZK_TIMEOUT));
-    assertEquals(ZooKeeperInstance.class.getSimpleName(), 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.TYPE)));
-
-    Instance instance = ConfiguratorBase.getInstance(this.getClass(), conf);
-    assertEquals(ZooKeeperInstance.class.getName(), 
instance.getClass().getName());
-    assertEquals("testInstanceName", 
((ZooKeeperInstance)instance).getInstanceName());
-    assertEquals("testZooKeepers", 
((ZooKeeperInstance)instance).getZooKeepers());
-    assertEquals(1234000, 
((ZooKeeperInstance)instance).getZooKeepersSessionTimeOut());
-  }
-
-  @Test
-  public void testSetMockInstance() {
-    Configuration conf = new Configuration();
-    ConfiguratorBase.setMockInstance(this.getClass(), conf, 
"testInstanceName");
-    assertEquals("testInstanceName", 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.NAME)));
-    assertEquals(null, 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.ZOO_KEEPERS)));
-    assertEquals(MockInstance.class.getSimpleName(), 
conf.get(ConfiguratorBase.enumToConfKey(this.getClass(), 
ConfiguratorBase.InstanceOpts.TYPE)));
-    Instance instance = ConfiguratorBase.getInstance(this.getClass(), conf);
-    assertEquals(MockInstance.class.getName(), instance.getClass().getName());
-  }
-
-  @Test
-  public void testSetLogLevel() {
-    Configuration conf = new Configuration();
-    Level currentLevel = Logger.getLogger(this.getClass()).getLevel();
-
-    ConfiguratorBase.setLogLevel(this.getClass(), conf, Level.DEBUG);
-    Logger.getLogger(this.getClass()).setLevel(currentLevel);
-    assertEquals(Level.DEBUG, ConfiguratorBase.getLogLevel(this.getClass(), 
conf));
-
-    ConfiguratorBase.setLogLevel(this.getClass(), conf, Level.INFO);
-    Logger.getLogger(this.getClass()).setLevel(currentLevel);
-    assertEquals(Level.INFO, ConfiguratorBase.getLogLevel(this.getClass(), 
conf));
-
-    ConfiguratorBase.setLogLevel(this.getClass(), conf, Level.FATAL);
-    Logger.getLogger(this.getClass()).setLevel(currentLevel);
-    assertEquals(Level.FATAL, ConfiguratorBase.getLogLevel(this.getClass(), 
conf));
-  }
-
-}

Reply via email to