/** * Setup a table with two rows and values. * * @param tableName the name of the table to create * @return A Table instance for the created table. * @throws IOException */ public static Table createTable(byte[] tableName) throws IOException { return createTable(tableName, new byte[][] { FAMILY }); }
@Test public void testDeprecatedExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase, " + "as it was given in 0.98."); final Table table = createTable(Bytes.toBytes("exampleDeprecatedTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleDeprecatedTIF.class); }
/** * Verify the example we present in javadocs on TableInputFormatBase */ @Test public void testExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase"); final Table table = createTable(Bytes.toBytes("exampleTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleTIF.class); }
@Test public void testJobConfigurableExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase, " + "using JobConfigurable."); final Table table = createTable(Bytes.toBytes("exampleJobConfigurableTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleJobConfigurableTIF.class); }
/** * Run test assuming no errors using mapred api. * * @throws IOException */ @Test public void testTableRecordReader() throws IOException { Table table = createTable("table1".getBytes()); runTestMapred(table); }
/** * Create a table that IOE's on first scanner next call * * @throws IOException */ static Table createIOEScannerTable(byte[] name, final int failCnt) throws IOException { // build up a mock scanner stuff to fail the first time Answer<ResultScanner> a = new Answer<ResultScanner>() { int cnt = 0; @Override public ResultScanner answer(InvocationOnMock invocation) throws Throwable { // first invocation return the busted mock scanner if (cnt++ < failCnt) { // create mock ResultScanner that always fails. Scan scan = mock(Scan.class); doReturn("bogus".getBytes()).when(scan).getStartRow(); // avoid npe ResultScanner scanner = mock(ResultScanner.class); // simulate TimeoutException / IOException doThrow(new IOException("Injected exception")).when(scanner).next(); return scanner; } // otherwise return the real scanner. return (ResultScanner) invocation.callRealMethod(); } }; Table htable = spy(createTable(name)); doAnswer(a).when(htable).getScanner((Scan) anyObject()); return htable; }
Table htable = spy(createTable(name)); doAnswer(a).when(htable).getScanner((Scan) anyObject()); return htable;
/** * Setup a table with two rows and values. * * @param tableName the name of the table to create * @return A Table instance for the created table. * @throws IOException */ public static Table createTable(byte[] tableName) throws IOException { return createTable(tableName, new byte[][] { FAMILY }); }
/** * Setup a table with two rows and values. * * @param tableName * @return * @throws IOException */ public static Table createTable(byte[] tableName) throws IOException { return createTable(tableName, new byte[][] { FAMILY }); }
@Test public void testDeprecatedExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase, " + "as it was given in 0.98."); final Table table = createTable(Bytes.toBytes("exampleDeprecatedTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleDeprecatedTIF.class); }
/** * Verify the example we present in javadocs on TableInputFormatBase */ @Test public void testExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase"); final Table table = createTable(Bytes.toBytes("exampleTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleTIF.class); }
@Test public void testJobConfigurableExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase, " + "using JobConfigurable."); final Table table = createTable(Bytes.toBytes("exampleJobConfigurableTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleJobConfigurableTIF.class); }
@Test public void testJobConfigurableExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase, " + "using JobConfigurable."); final Table table = createTable(Bytes.toBytes("exampleJobConfigurableTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleJobConfigurableTIF.class); }
/** * Verify the example we present in javadocs on TableInputFormatBase */ @Test public void testExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase"); final Table table = createTable(Bytes.toBytes("exampleTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleTIF.class); }
@Test public void testDeprecatedExtensionOfTableInputFormatBase() throws IOException { LOG.info("testing use of an InputFormat taht extends InputFormatBase, " + "as it was given in 0.98."); final Table table = createTable(Bytes.toBytes("exampleDeprecatedTable"), new byte[][] { Bytes.toBytes("columnA"), Bytes.toBytes("columnB") }); testInputFormat(ExampleDeprecatedTIF.class); }
/** * Run test assuming no errors using mapred api. * * @throws IOException */ @Test public void testTableRecordReader() throws IOException { Table table = createTable("table1".getBytes()); runTestMapred(table); }
/** * Run test assuming no errors using mapred api. * * @throws IOException */ @Test public void testTableRecordReader() throws IOException { Table table = createTable("table1".getBytes()); runTestMapred(table); }
/** * Create a table that IOE's on first scanner next call * * @throws IOException */ static Table createIOEScannerTable(byte[] name, final int failCnt) throws IOException { // build up a mock scanner stuff to fail the first time Answer<ResultScanner> a = new Answer<ResultScanner>() { int cnt = 0; @Override public ResultScanner answer(InvocationOnMock invocation) throws Throwable { // first invocation return the busted mock scanner if (cnt++ < failCnt) { // create mock ResultScanner that always fails. Scan scan = mock(Scan.class); doReturn("bogus".getBytes()).when(scan).getStartRow(); // avoid npe ResultScanner scanner = mock(ResultScanner.class); // simulate TimeoutException / IOException doThrow(new IOException("Injected exception")).when(scanner).next(); return scanner; } // otherwise return the real scanner. return (ResultScanner) invocation.callRealMethod(); } }; Table htable = spy(createTable(name)); doAnswer(a).when(htable).getScanner((Scan) anyObject()); return htable; }
/** * Create a table that IOE's on first scanner next call * * @throws IOException */ static Table createIOEScannerTable(byte[] name, final int failCnt) throws IOException { // build up a mock scanner stuff to fail the first time Answer<ResultScanner> a = new Answer<ResultScanner>() { int cnt = 0; @Override public ResultScanner answer(InvocationOnMock invocation) throws Throwable { // first invocation return the busted mock scanner if (cnt++ < failCnt) { // create mock ResultScanner that always fails. Scan scan = mock(Scan.class); doReturn("bogus".getBytes()).when(scan).getStartRow(); // avoid npe ResultScanner scanner = mock(ResultScanner.class); // simulate TimeoutException / IOException doThrow(new IOException("Injected exception")).when(scanner).next(); return scanner; } // otherwise return the real scanner. return (ResultScanner) invocation.callRealMethod(); } }; Table htable = spy(createTable(name)); doAnswer(a).when(htable).getScanner((Scan) anyObject()); return htable; }
Table htable = spy(createTable(name)); doAnswer(a).when(htable).getScanner((Scan) anyObject()); return htable;