@Test public void testExceptionForNoManager() throws IOException { Configuration conf = new Configuration(); conf.set(ConnFactory.FACTORY_CLASS_NAMES_KEY, EmptyFactory.class.getName()); ConnFactory factory = new ConnFactory(conf); thrown.expect(IOException.class); thrown.reportMissingExceptionWithMessage("Expected IOException because of missing ConnManager "); factory.getManager( new JobData(new SqoopOptions(), new ImportTool())); }
@Test public void testMultipleManagers() throws IOException { Configuration conf = new Configuration(); // The AlwaysDummyFactory is second in this list. Nevertheless, since // we know the first factory in the list will return null, we should still // get a DummyManager out. String classNames = EmptyFactory.class.getName() + "," + AlwaysDummyFactory.class.getName(); conf.set(ConnFactory.FACTORY_CLASS_NAMES_KEY, classNames); ConnFactory factory = new ConnFactory(conf); ConnManager manager = factory.getManager( new JobData(new SqoopOptions(), new ImportTool())); assertNotNull("No manager returned", manager); assertTrue("Expected a DummyManager", manager instanceof DummyManager); }
@Test public void testCustomFactory() throws IOException { Configuration conf = new Configuration(); conf.set(ConnFactory.FACTORY_CLASS_NAMES_KEY, AlwaysDummyFactory.class.getName()); ConnFactory factory = new ConnFactory(conf); ConnManager manager = factory.getManager( new JobData(new SqoopOptions(), new ImportTool())); assertNotNull("No manager returned", manager); assertTrue("Expected a DummyManager", manager instanceof DummyManager); }
@Before public void setUp() { Configuration conf = getConf(); opts = getSqoopOptions(conf); opts.setConnectString("dummy.server"); opts.setTableName("dummy.pds"); opts.setConnManagerClassName(MainframeManager.class.getName()); context = new ImportJobContext(getTableName(), null, opts, null); ConnFactory f = new ConnFactory(conf); try { this.manager = f.getManager(new JobData(opts, new MainframeImportTool())); } catch (IOException ioe) { fail("IOException instantiating manager: " + StringUtils.stringifyException(ioe)); } }
@Before public void setUp() { MSSQLTestUtils utils = new MSSQLTestUtils(); try { utils.createTableFromSQL(MSSQLTestUtils.CREATE_TALBE_LINEITEM); utils.populateLineItem(); } catch (SQLException e) { LOG.error("Setup fail with SQLException: " + StringUtils.stringifyException(e)); fail("Setup fail with SQLException: " + e.toString()); } Configuration conf = getConf(); SqoopOptions opts = getSqoopOptions(conf); String username = MSSQLTestUtils.getDBUserName(); String password = MSSQLTestUtils.getDBPassWord(); opts.setUsername(username); opts.setPassword(password); opts.setConnectString(getConnectString()); ConnFactory f = new ConnFactory(conf); try { this.manager = f.getManager(new JobData(opts, new ImportTool())); System.out.println("Manger : " + this.manager); } catch (IOException ioe) { LOG.error("Setup fail with IOException: " + StringUtils.stringifyException(ioe)); fail("IOException instantiating manager: " + StringUtils.stringifyException(ioe)); } }
opts.setConnectString(getConnectString()); opts.setTableName(getTableName()); ConnFactory f = new ConnFactory(conf); try { this.manager = f.getManager(new JobData(opts, new ImportTool())); } catch (IOException ioe) { fail("IOException instantiating manager: "