@Test public void valueOfOracleEscapingDisabledShouldBeEqualToNullIfASqoopOptionsInstanceWasLoadedWhichDidntContainASavedValueForIt() { System.clearProperty(SqoopOptions.ORACLE_ESCAPING_DISABLED); SqoopOptions opts = new SqoopOptions(); Properties out = opts.writeProperties(); opts = new SqoopOptions(); opts.loadProperties(out); assertThat(opts.isOracleEscapingDisabled(), is(equalTo(true))); assertThat(OracleUtils.isOracleEscapingDisabled(opts.getConf()), is(equalTo(true))); }
@Test public void valueOfOracleEscapingDisabledShouldBeAbleToSavedAndLoadedBackWithTheSameValue() { System.clearProperty(SqoopOptions.ORACLE_ESCAPING_DISABLED); SqoopOptions opts = new SqoopOptions(); opts.setOracleEscapingDisabled(false); Properties out = opts.writeProperties(); opts = new SqoopOptions(); opts.loadProperties(out); assertThat(opts.isOracleEscapingDisabled(), is(equalTo(false))); assertThat(OracleUtils.isOracleEscapingDisabled(opts.getConf()), is(equalTo(false))); }
@Test public void testDefaultLoadedThrowOnErrorWithNotSetSystemProperty() { System.clearProperty(SQOOP_RETHROW_PROPERTY); SqoopOptions out = new SqoopOptions(); Properties props = out.writeProperties(); SqoopOptions opts = new SqoopOptions(); opts.loadProperties(props); assertFalse(opts.isThrowOnError()); }
@Test public void testDefaultLoadedThrowOnErrorWithSetSystemProperty() { String testSqoopRethrowProperty = ""; System.setProperty(SQOOP_RETHROW_PROPERTY, testSqoopRethrowProperty); SqoopOptions out = new SqoopOptions(); Properties props = out.writeProperties(); SqoopOptions opts = new SqoopOptions(); opts.loadProperties(props); assertTrue(opts.isThrowOnError()); }
@Test public void testDefaultLoadedTempRootDir() { SqoopOptions out = new SqoopOptions(); Properties props = out.writeProperties(); SqoopOptions opts = new SqoopOptions(); opts.loadProperties(props); assertEquals("_sqoop", opts.getTempRootDir()); }
@Test public void testPasswordInMetastoreWithRecordEnabledAndNonSecureOption() throws Exception { ArrayList<String> extraArgs = new ArrayList<String>(); extraArgs.add("--username"); extraArgs.add("username"); extraArgs.add("--password"); extraArgs.add("password"); String[] argv = getCommonArgs(false, extraArgs); Configuration conf = getConf(); SqoopOptions in = getSqoopOptions(conf); ImportTool importTool = new ImportTool(); SqoopOptions out = importTool.parseArguments(argv, conf, in, true); assertNotNull(out.getPassword()); // Enable storing passwords in the metastore conf.set(SqoopOptions.METASTORE_PASSWORD_KEY, "true"); // this is what is used to record password into the metastore Properties propertiesIntoMetastore = out.writeProperties(); assertNotNull(propertiesIntoMetastore.getProperty(DB_PASSWORD_KEY)); assertNull(propertiesIntoMetastore.getProperty("db.password.file")); // load the saved properties and verify SqoopOptions optionsFromMetastore = new SqoopOptions(); optionsFromMetastore.loadProperties(propertiesIntoMetastore); assertNotNull(optionsFromMetastore.getPassword()); assertNull(optionsFromMetastore.getPasswordFilePath()); }
@Test public void testLoadedTempRootDir() { SqoopOptions out = new SqoopOptions(); final String tempRootDir = "customRoot"; out.setTempRootDir(tempRootDir); Properties props = out.writeProperties(); SqoopOptions opts = new SqoopOptions(); opts.loadProperties(props); assertEquals(tempRootDir, opts.getTempRootDir()); }
@Test public void testNulledTempRootDir() { SqoopOptions out = new SqoopOptions(); out.setTempRootDir(null); Properties props = out.writeProperties(); SqoopOptions opts = new SqoopOptions(); opts.loadProperties(props); assertEquals("_sqoop", opts.getTempRootDir()); }
@Test public void testPasswordInMetastoreWithRecordDisabledAndSecureOption() throws Exception { String passwordFilePath = BaseSqoopTestCase.getTempBaseDir() + ".pwd"; createTempFile(passwordFilePath); ArrayList<String> extraArgs = new ArrayList<String>(); extraArgs.add("--username"); extraArgs.add("username"); extraArgs.add("--password-file"); extraArgs.add(passwordFilePath); String[] argv = getCommonArgs(false, extraArgs); Configuration conf = getConf(); SqoopOptions in = getSqoopOptions(conf); ImportTool importTool = new ImportTool(); SqoopOptions out = importTool.parseArguments(argv, conf, in, true); assertNotNull(out.getPassword()); // Enable storing passwords in the metastore conf.set(SqoopOptions.METASTORE_PASSWORD_KEY, "false"); // this is what is used to record password into the metastore Properties propertiesIntoMetastore = out.writeProperties(); assertNull(propertiesIntoMetastore.getProperty(DB_PASSWORD_KEY)); assertNotNull(propertiesIntoMetastore.getProperty("db.password.file")); // load the saved properties and verify SqoopOptions optionsFromMetastore = new SqoopOptions(); optionsFromMetastore.loadProperties(propertiesIntoMetastore); assertNotNull(optionsFromMetastore.getPassword()); assertNotNull(optionsFromMetastore.getPasswordFilePath()); assertEquals(passwordFilePath, optionsFromMetastore.getPasswordFilePath()); }
@Test public void testPasswordInMetastoreWithRecordEnabledAndSecureOption() throws Exception { String passwordFilePath = BaseSqoopTestCase.getTempBaseDir() + ".pwd"; createTempFile(passwordFilePath); ArrayList<String> extraArgs = new ArrayList<String>(); extraArgs.add("--username"); extraArgs.add("username"); extraArgs.add("--password-file"); extraArgs.add(passwordFilePath); String[] argv = getCommonArgs(false, extraArgs); Configuration conf = getConf(); SqoopOptions in = getSqoopOptions(conf); ImportTool importTool = new ImportTool(); SqoopOptions out = importTool.parseArguments(argv, conf, in, true); assertNotNull(out.getPassword()); // Enable storing passwords in the metastore conf.set(SqoopOptions.METASTORE_PASSWORD_KEY, "true"); // this is what is used to record password into the metastore Properties propertiesIntoMetastore = out.writeProperties(); assertNull(propertiesIntoMetastore.getProperty(DB_PASSWORD_KEY)); // password-file should NOT be null as it'll be sued to retrieve password assertNotNull(propertiesIntoMetastore.getProperty("db.password.file")); // load the saved properties and verify SqoopOptions optionsFromMetastore = new SqoopOptions(); optionsFromMetastore.loadProperties(propertiesIntoMetastore); assertNotNull(optionsFromMetastore.getPassword()); assertNotNull(optionsFromMetastore.getPasswordFilePath()); assertEquals(passwordFilePath, optionsFromMetastore.getPasswordFilePath()); }
in.loadProperties(outProps);
in.loadProperties(outProps);