src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
LazyStatementHandler extends CallableStatementHandler { @Override public void setStatement(Statement statement, QueryParameters params) throws SQLException { super.setStatement(statement, params); } LazyStatementHandler(Overrider overrider); @Override void setStatement(Statement statement, QueryParameters params); @Ove... | @Test public void testSetStatement() throws Exception { } |
MjdbcLogger extends Logger { public static boolean isSLF4jImplementationAvailable() { if (SLF4jImplementationAvailable == null) { if (isSLF4jAvailable() == true) { try { Object obj = MappingUtils.invokeStaticFunction(Class.forName("org.slf4j.LoggerFactory"), "getILoggerFactory", new Class[]{}, new Object[]{}); if (obj.... | @Test public void testIsSLF4jImplementationAvailable() throws Exception { Assert.assertEquals(false, MjdbcLogger.isSLF4jImplementationAvailable()); } |
QueryRunner extends AbstractQueryRunner { public int[] batch(String sql, Object[][] params) throws SQLException { AssertUtils.assertNotNull(sql, nullException()); AssertUtils.assertNotNull(params, nullException()); return this.batch(this.getStatementHandler(), sql, getQueryParams(params)); } QueryRunner(DataSource ds);... | @Test public void testBatch1NoValue() throws Exception { queryRunner.batch("", new Object[0][0]); verify(transactionHandler, times(1)).getConnection(); verify(transactionHandler, times(1)).commit(); verify(transactionHandler, times(1)).closeConnection(); verify(conn, times(1)).prepareStatement(any(String.class)); verif... |
QueryRunner extends AbstractQueryRunner { public <T> T query(String sql, OutputHandler<T> outputHandler, Object... params) throws SQLException { AssertUtils.assertNotNull(sql, nullException()); AssertUtils.assertNotNull(outputHandler, nullException()); return this.<T>query(this.getStatementHandler(), sql, outputHandler... | @Test(expected = java.sql.SQLException.class) public void testQuery1SqlNull() throws Exception { queryRunner.query((String) null, new MapOutputHandler()); }
@Test(expected = java.sql.SQLException.class) public void testQuery1ParamNull() throws Exception { queryRunner.query("", null); }
@Test(expected = IllegalArgumentE... |
LazyStatementHandler extends CallableStatementHandler { @Override public List<QueryParameters> wrap(Statement stmt) throws SQLException { QueryParametersLazyList result = null; ResultSet rs = null; boolean readGeneratedKeys = false; if (this.overrider.hasOverride(MjdbcConstants.OVERRIDE_INT_GET_GENERATED_KEYS) == true)... | @Test public void testWrap() throws Exception { when(stmt.getResultSet()).thenReturn(rs); new LazyStatementHandler(new Overrider()).wrap(stmt); verify(stmt, times(1)).getResultSet(); verify(stmt, never()).getMoreResults(); verify(rs, never()).next(); } |
QueryRunner extends AbstractQueryRunner { public int update(String sql) throws SQLException { AssertUtils.assertNotNull(sql, nullException()); Integer rows = (Integer) this.update(this.getStatementHandler(), sql, HandlersConstants.UPDATE_ROW_COUNT_HANDLER, HandlersConstants.EMPTY_QUERY_PARAMS); return rows.intValue(); ... | @Test(expected = java.sql.SQLException.class) public void testUpdate1SqlNull() throws Exception { queryRunner.update((String) null); }
@Test public void testUpdate2Value() throws Exception { queryRunner.update("SQL", "bla"); verify(transactionHandler, times(1)).getConnection(); verify(transactionHandler, times(1)).comm... |
BaseStatementHandler implements StatementHandler { public void setStatement(Statement statement, QueryParameters params) throws SQLException { AssertUtils.assertNotNull(params); PreparedStatement preparedStmt = (PreparedStatement) statement; ParameterMetaData pmd = null; int stmtCount = -1; int paramsCount = params == ... | @Test public void testSetStatement() throws Exception { invokeQueries(); verify(preparedStatement, times(3)).setObject(1, "luck"); verify(preparedStatement, times(3)).setNull(eq(2), any(int.class)); verify(preparedStatement, never()).setNull(eq(3), any(int.class)); verify(preparedStatement, never()).setObject(eq(3), an... |
BaseStatementHandler implements StatementHandler { public List<QueryParameters> wrap(Statement stmt) throws SQLException { List<QueryParameters> mergedResult = new ArrayList<QueryParameters>(); List<QueryParameters> converted = null; ResultSet rs = null; List<ResultSet> closedResultSet = new ArrayList<ResultSet>(); Que... | @Test public void testWrap() throws Exception { invokeQueries(); verify(preparedStatement, times(2)).getUpdateCount(); verify(preparedStatement, times(2)).getGeneratedKeys(); verify(preparedStatement, times(2)).getResultSet(); verify(callableStatement, times(1)).getUpdateCount(); verify(callableStatement, times(1)).get... |
QueryRunner extends AbstractQueryRunner { public QueryParameters call(AbstractQueryInputHandler inputHandler) throws SQLException { return callInner(inputHandler, null); } QueryRunner(DataSource ds); QueryRunner(Connection conn); QueryRunner(DataSource ds, Class<? extends TypeHandler> typeHandlerClazz); QueryRunner(... | @Test(expected = IllegalArgumentException.class) public void testCall1SqlNull() throws Exception { queryRunner.call(new MapInputHandler(null, new HashMap<String, Object>() {{ put("value", "bla"); }})); }
@Test(expected = IllegalArgumentException.class) public void testCall1SqlIncorrect() throws Exception { queryRunner.... |
BaseStatementHandler implements StatementHandler { public Object[] readStatement(Statement statement, QueryParameters params) throws SQLException { return new Object[params.orderSize()]; } BaseStatementHandler(Overrider overrider); void setStatement(Statement statement, QueryParameters params); List<QueryParameters> wr... | @Test public void testReadStatement() throws Exception { } |
BaseStatementHandler implements StatementHandler { public void beforeClose() { } BaseStatementHandler(Overrider overrider); void setStatement(Statement statement, QueryParameters params); List<QueryParameters> wrap(Statement stmt); Object[] readStatement(Statement statement, QueryParameters params); void beforeClose();... | @Test public void testBeforeClose() throws Exception { } |
QueryRunner extends AbstractQueryRunner { public <T> T execute(AbstractXmlInputOutputHandler<T> inputHandler) throws SQLException { T result = null; Overrider queryOverride = inputHandler.getOverrides(); String operationType = (String) queryOverride.getOverride(XmlParameters.operationType); if (queryOverride.hasOverrid... | @Test(expected = MjdbcRuntimeException.class) public void testExecuteException1() throws SQLException { Overrider overrider1 = new Overrider(); overrider1.override(XmlParameters.operationType, "call"); when(xmlInputOutputHandler.getOverrides()).thenReturn(overrider1); queryRunner.execute(xmlInputOutputHandler); }
@Test... |
BaseStatementHandler implements StatementHandler { public void afterClose() { } BaseStatementHandler(Overrider overrider); void setStatement(Statement statement, QueryParameters params); List<QueryParameters> wrap(Statement stmt); Object[] readStatement(Statement statement, QueryParameters params); void beforeClose(); ... | @Test public void testAfterClose() throws Exception { } |
BasicQueryOutputProcessor implements QueryOutputProcessor { public Object[] toArray(List<QueryParameters> paramsList) { Object[] result = new Object[0]; QueryParameters singleParam = null; String parameterName = null; Iterator<QueryParameters> iterator = paramsList.iterator(); if (iterator.hasNext() == true) { iterator... | @Test public void testToArray() throws Exception { QueryParameters params = new QueryParameters(); Object[] expected = new Object[]{"8", "7", "4"}; params.set("intelligence", expected[0]); params.set("charisma", expected[1]); params.set("strength", expected[2]); paramsList.add(params); Object[] result = queryOutputProc... |
BasicQueryOutputProcessor implements QueryOutputProcessor { public List<Object[]> toArrayList(List<QueryParameters> paramsList) { List<Object[]> result = new ArrayList<Object[]>(); QueryParameters singleParam = null; Object[] singleResult = null; String parameterName = null; Iterator<QueryParameters> iterator = paramsL... | @Test public void testToArrayList() throws Exception { QueryParameters params = null; Object[] expected = new Object[]{"8", "7", "4"}; params = new QueryParameters(); params.set("intelligence", expected[0]); params.set("charisma", expected[1]); params.set("strength", expected[2]); paramsList.add(params); params = new Q... |
BasicQueryOutputProcessor implements QueryOutputProcessor { public <T> List<T> toBeanList(List<QueryParameters> paramsList, Class<T> type) throws MjdbcException { List<T> result = new ArrayList<T>(); T bean = null; int[] columnToProperty = null; PropertyDescriptor[] props = MappingUtils.propertyDescriptors(type); Query... | @Test public void testToBeanList() throws Exception { QueryParameters params1 = null; QueryParameters params2 = null; int age1 = 5; String name1 = "whiskers"; int age2 = 10; String name2 = "lucky"; params1 = new QueryParameters(); params1.set("age", age1); params1.set("name", name1); paramsList.add(params1); params2 = ... |
BasicQueryOutputProcessor implements QueryOutputProcessor { public List<Map<String, Object>> toMapList(List<QueryParameters> paramsList) { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); Iterator<QueryParameters> iterator = paramsList.iterator(); if (iterator.hasNext() == true) { iterator.next(... | @Test public void testToMapList() throws Exception { QueryParameters params1 = null; QueryParameters params2 = null; int age1 = 5; String name1 = "whiskers"; int age2 = 10; String name2 = "lucky"; params1 = new QueryParameters(); params1.set("age", age1); params1.set("name", name1); paramsList.add(params1); params2 = n... |
BasicQueryOutputProcessor implements QueryOutputProcessor { public Object processValue(QueryParameters params, Integer position, PropertyDescriptor prop) throws MjdbcException { String parameterName = params.getNameByPosition(position); Object value = params.getValue(parameterName); Class<?> propType = prop.getProperty... | @Test public void testProcessValue() throws Exception { long expectedTime = 100; java.util.Date resultTime = null; QueryParameters params = new QueryParameters(); params.set("date", new Date(expectedTime)); params.set("time", new Time(expectedTime + 10)); params.set("timestamp", new Timestamp(expectedTime + 20)); param... |
BasicQueryOutputProcessor implements QueryOutputProcessor { public Map<String, Object> toMap(List<QueryParameters> paramsList) { Map<String, Object> result = null; Iterator<QueryParameters> iterator = paramsList.iterator(); if (iterator.hasNext() == true) { iterator.next(); } if (iterator.hasNext() == true) { result = ... | @Test public void testToMapNull() { Assert.assertEquals(null, queryOutputProcessor.toMap((QueryParameters) null)); } |
BasicQueryOutputProcessor implements QueryOutputProcessor { public <T> T toBean(List<QueryParameters> paramsList, Class<T> type) throws MjdbcException { T result = null; Iterator<QueryParameters> iterator = paramsList.iterator(); if (iterator.hasNext() == true) { iterator.next(); } if (iterator.hasNext() == true) { res... | @Test public void testToBeanNull() throws MjdbcException { Assert.assertEquals(null, queryOutputProcessor.toBean((QueryParameters) null, Cat.class)); } |
MidaoConfig { public static QueryInputProcessor getDefaultQueryInputProcessor() { return MjdbcConfig.getDefaultQueryInputProcessor(); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProce... | @Test public void testGetDefaultQueryInputProcessor() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultQueryInputProcessor() instanceof QueryInputProcessor); } |
MidaoConfig { public static boolean isQueryInputProcessorUseCache() { return MjdbcConfig.isQueryInputProcessorUseCache(); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUseCache... | @Test public void testIsQueryInputProcessorUseCache() throws Exception { boolean defaultValue = MidaoConfig.isQueryInputProcessorUseCache(); MidaoConfig.setQueryInputProcessorUseCache(!defaultValue); Assert.assertEquals(!defaultValue, MidaoConfig.isQueryInputProcessorUseCache()); MidaoConfig.setQueryInputProcessorUseCa... |
MidaoConfig { public static QueryOutputProcessor getDefaultQueryOutputProcessor() { return MjdbcConfig.getDefaultQueryOutputProcessor(); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputPr... | @Test public void testGetDefaultQueryOutputProcessor() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultQueryOutputProcessor() instanceof QueryOutputProcessor); } |
MjdbcConfig { public static QueryInputProcessor getDefaultQueryInputProcessor() { return instance().defaultQueryInputProcessor; } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUs... | @Test public void testGetDefaultQueryInputProcessor() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultQueryInputProcessor() instanceof QueryInputProcessor); } |
MidaoConfig { public static StatementHandler getDefaultStatementHandler(Overrider overrider) { return MjdbcConfig.getDefaultStatementHandler(overrider); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolea... | @Test public void testGetDefaultStatementHandler() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultStatementHandler(overrider) instanceof StatementHandler); } |
MidaoConfig { public static TypeHandler getDefaultTypeHandler(Overrider overrider) { return MjdbcConfig.getDefaultTypeHandler(overrider); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputP... | @Test public void testGetDefaultTypeHandler() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultTypeHandler(overrider) instanceof TypeHandler); } |
MidaoConfig { public static TransactionHandler getDefaultTransactionHandler(Connection conn) { return MjdbcConfig.getDefaultTransactionHandler(conn); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean i... | @Test public void testGetDefaultTransactionHandlerConn() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultTransactionHandler(conn) instanceof TransactionHandler); }
@Test public void testGetDefaultTransactionHandlerDataSource() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultTransac... |
MidaoConfig { public static ExceptionHandler getDefaultExceptionHandler(String dbName) { return MjdbcConfig.getDefaultExceptionHandler(dbName); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQuery... | @Test public void testGetDefaultExceptionHandler() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultExceptionHandler("") instanceof ExceptionHandler); } |
MidaoConfig { public static MetadataHandler getDefaultMetadataHandler(Connection conn) { return MjdbcConfig.getDefaultMetadataHandler(conn); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInp... | @Test public void testGetDefaultMetadataHandlerConn() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultMetadataHandler(conn) instanceof MetadataHandler); }
@Test public void testGetDefaultMetadataHandlerDataSource() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultMetadataHandler(ds)... |
MidaoConfig { public static Overrider getDefaultOverrider() { return MjdbcConfig.getDefaultOverrider(); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUseCache(); static void se... | @Test public void testGetDefaultOverrider() throws Exception { Assert.assertEquals(true, MidaoConfig.getDefaultOverrider() instanceof Overrider); } |
MidaoConfig { public static boolean isProfilerEnabled() { return MjdbcConfig.isProfilerEnabled(); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUseCache(); static void setQuery... | @Test public void testIsProfilerEnabled() throws Exception { boolean defaultValue = MidaoConfig.isProfilerEnabled(); MidaoConfig.setProfilerEnabled(!defaultValue); Assert.assertEquals(!defaultValue, MidaoConfig.isProfilerEnabled()); MidaoConfig.setProfilerEnabled(defaultValue); } |
MidaoConfig { public static String getProfilerOutputFormat() { return MjdbcConfig.getProfilerOutputFormat(); } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUseCache(); static vo... | @Test public void testGetProfilerOutputFormat() throws Exception { Assert.assertEquals(true, MidaoConfig.getProfilerOutputFormat() != null && MidaoConfig.getProfilerOutputFormat().length() > 0); } |
MjdbcConfig { public static boolean isQueryInputProcessorUseCache() { return instance().queryInputProcessorUseCache; } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUseCache(); s... | @Test public void testIsQueryInputProcessorUseCache() throws Exception { boolean defaultValue = MjdbcConfig.isQueryInputProcessorUseCache(); MjdbcConfig.setQueryInputProcessorUseCache(!defaultValue); Assert.assertEquals(!defaultValue, MjdbcConfig.isQueryInputProcessorUseCache()); MjdbcConfig.setQueryInputProcessorUseCa... |
MjdbcConfig { public static QueryOutputProcessor getDefaultQueryOutputProcessor() { return instance().defaultQueryOutputProcessor; } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcesso... | @Test public void testGetDefaultQueryOutputProcessor() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultQueryOutputProcessor() instanceof QueryOutputProcessor); } |
MjdbcConfig { public static StatementHandler getDefaultStatementHandler(Overrider overrider) { StatementHandler result = null; Constructor<? extends StatementHandler> constructor = null; Class<? extends StatementHandler> clazz = instance().defaultStatementHandler; try { constructor = clazz.getConstructor(Overrider.clas... | @Test public void testGetDefaultStatementHandler() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultStatementHandler(overrider) instanceof StatementHandler); } |
MjdbcConfig { public static TypeHandler getDefaultTypeHandler(Overrider overrider) { TypeHandler result = null; Constructor<? extends TypeHandler> constructor = null; Class<? extends TypeHandler> clazz = instance().defaultTypeHandler; try { constructor = clazz.getConstructor(Overrider.class); result = constructor.newIn... | @Test public void testGetDefaultTypeHandler() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultTypeHandler(overrider) instanceof TypeHandler); } |
MjdbcConfig { public static TransactionHandler getDefaultTransactionHandler(Connection conn) { TransactionHandler result = null; Constructor<?> constructor = null; Class<?> clazz = instance().defaultTransactionHandler; try { constructor = clazz.getConstructor(Connection.class); result = (TransactionHandler) constructor... | @Test public void testGetDefaultTransactionHandlerConn() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultTransactionHandler(conn) instanceof TransactionHandler); }
@Test public void testGetDefaultTransactionHandlerDataSource() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultTransac... |
MjdbcConfig { public static ExceptionHandler getDefaultExceptionHandler(String dbName) { ExceptionHandler result = null; Constructor<?> constructor = null; Class<?> clazz = instance().defaultExceptionHandler; try { constructor = clazz.getConstructor(String.class); result = (ExceptionHandler) constructor.newInstance(dbN... | @Test public void testGetDefaultExceptionHandler() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultExceptionHandler("") instanceof ExceptionHandler); } |
MjdbcConfig { public static MetadataHandler getDefaultMetadataHandler(Connection conn) { MetadataHandler result = null; Constructor<?> constructor = null; Class<?> clazz = instance().defaultMetadataHandler; try { constructor = clazz.getConstructor(Connection.class, boolean.class); result = (MetadataHandler) constructor... | @Test public void testGetDefaultMetadataHandlerConn() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultMetadataHandler(conn) instanceof MetadataHandler); }
@Test public void testGetDefaultMetadataHandlerDataSource() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultMetadataHandler(ds)... |
MjdbcConfig { public static Overrider getDefaultOverrider() { Overrider result = null; Class<Overrider> clazz = instance().defaultOverrider; try { result = clazz.newInstance(); } catch (InstantiationException e) { throw new MjdbcRuntimeException(ERROR_OR_INIT_FAILED, e); } catch (IllegalAccessException e) { throw new M... | @Test public void testGetDefaultOverrider() throws Exception { Assert.assertEquals(true, MjdbcConfig.getDefaultOverrider() instanceof Overrider); } |
MjdbcConfig { public static boolean isProfilerEnabled() { return instance().profilerEnabled; } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUseCache(); static void setQueryInput... | @Test public void testIsProfilerEnabled() throws Exception { boolean defaultValue = MjdbcConfig.isProfilerEnabled(); MjdbcConfig.setProfilerEnabled(!defaultValue); Assert.assertEquals(!defaultValue, MjdbcConfig.isProfilerEnabled()); MjdbcConfig.setProfilerEnabled(defaultValue); } |
MjdbcConfig { public static String getProfilerOutputFormat() { return instance().profilerOutputFormat; } static QueryInputProcessor getDefaultQueryInputProcessor(); static void setDefaultQueryInputProcessor(QueryInputProcessor defaultQueryInputProcessor); static boolean isQueryInputProcessorUseCache(); static void set... | @Test public void testGetProfilerOutputFormat() throws Exception { Assert.assertEquals(true, MjdbcConfig.getProfilerOutputFormat() != null && MjdbcConfig.getProfilerOutputFormat().length() > 0); } |
XmlRepositoryFactory { public static Document getDocument(File file) { InputStream inputStream = null; try { inputStream = new FileInputStream(file); } catch (FileNotFoundException ex) { throw new MjdbcRuntimeException(ex); } return XmlRepositoryFactory.getDocument(inputStream); } static Document getDocument(File file... | @Test public void testGetDocumentStream() throws Exception { Document document = XmlRepositoryFactory.getDocument(new ByteArrayInputStream(xmlQuery.getBytes())); Assert.assertNotNull(document); }
@Test public void testGetDocumentStreamMultiThreadedUsage() throws Exception { final Runnable runnable = new Runnable() { @O... |
XmlRepositoryFactory { public static void remove(String name) { xmlQueryString.remove(name); xmlOverrideMap.remove(name); } static Document getDocument(File file); static Document getDocument(InputStream inputStream); static void add(Document document, String name); static void add(Element element); static void addAll... | @Test public void testRemove() throws Exception { XmlRepositoryFactory.addAll(XmlRepositoryFactory.getDocument(new ByteArrayInputStream( xmlQuery.getBytes() ))); Assert.assertNotNull(XmlRepositoryFactory.getQueryString("findOne")); XmlRepositoryFactory.remove("findOne"); try { XmlRepositoryFactory.getQueryString("findO... |
XmlRepositoryFactory { public static void refresh(Document document) { refresh(document, document); } static Document getDocument(File file); static Document getDocument(InputStream inputStream); static void add(Document document, String name); static void add(Element element); static void addAll(Document document); s... | @Test public void testRefresh() throws Exception { XmlRepositoryFactory.addAll(XmlRepositoryFactory.getDocument(new ByteArrayInputStream( xmlQuery.getBytes() ))); Assert.assertEquals("SELECT ID FROM CATS WHERE AGE=#{age} AND NAME = #{name}", XmlRepositoryFactory.getQueryString("findOne")); Document document = XmlReposi... |
XmlRepositoryFactory { public static boolean isAutoRefresh() { return autoRefresh; } static Document getDocument(File file); static Document getDocument(InputStream inputStream); static void add(Document document, String name); static void add(Element element); static void addAll(Document document); static void addAll... | @Test public void testIsAutoRefresh() throws Exception { } |
XmlRepositoryFactory { public static void setAutoRefresh(boolean autoRefresh) { XmlRepositoryFactory.autoRefresh = autoRefresh; } static Document getDocument(File file); static Document getDocument(InputStream inputStream); static void add(Document document, String name); static void add(Element element); static void ... | @Test public void testSetAutoRefresh() throws Exception { } |
XmlRepositoryFactory { static String getQueryString(String name) { String result = null; if (xmlQueryString.containsKey(name) == false) { throw new MjdbcRuntimeException("Failed to find query by name: " + name + ". Please ensure that relevant file was loaded into repository"); } result = xmlQueryString.get(name); retur... | @Test public void testGetQueryString() throws Exception { XmlRepositoryFactory.addAll(XmlRepositoryFactory.getDocument(new ByteArrayInputStream( xmlQuery.getBytes() ))); Assert.assertNotNull(XmlRepositoryFactory.getQueryString("findOne")); } |
XmlRepositoryFactory { static Overrider getOverride(AbstractXmlInputOutputHandler inputHandler) { AssertUtils.assertNotNull(inputHandler); Overrider result = null; if (xmlOverrideMap.containsKey(inputHandler.getName()) == false) { throw new MjdbcRuntimeException("Failed to find query by name: " + inputHandler.getName()... | @Test public void testGetOverride() throws Exception { XmlRepositoryFactory.addAll(XmlRepositoryFactory.getDocument(new ByteArrayInputStream( xmlQuery.getBytes() ))); XmlInputOutputHandler handler = new XmlInputOutputHandler("findOne", catMap); Assert.assertNotNull(XmlRepositoryFactory.getOverride(handler)); } |
XmlRepositoryFactory { static OutputHandler getOutputHandler(AbstractXmlInputOutputHandler inputHandler) { AssertUtils.assertNotNull(inputHandler); OutputHandler outputHandler = null; String outputHandlerClassName = (String) getOverride(inputHandler).getOverride(XmlParameters.outputHandler); if (outputHandlerClassName.... | @Test public void testGetOutputHandler() throws Exception { XmlRepositoryFactory.addAll(XmlRepositoryFactory.getDocument(new ByteArrayInputStream( xmlQuery.getBytes() ))); XmlInputOutputHandler handler = new XmlInputOutputHandler("findOne", catMap); Assert.assertNotNull(XmlRepositoryFactory.getOutputHandler(handler)); ... |
QueryParametersLazyList implements List<QueryParameters> { public void setMaxCacheSize(int maxCacheSize) { if (maxCacheSize == 0) { this.maxCacheSize = 1; } else if (maxCacheSize < 0) { this.maxCacheSize = -1; } else { this.maxCacheSize = maxCacheSize; } } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler... | @Test public void testSetMaxCacheSize() throws Exception { queryParametersLazyList.get(1); Assert.assertEquals(2, queryParametersLazyList.sizeCached()); queryParametersLazyList.setMaxCacheSize(1); queryParametersLazyList.get(2); Assert.assertEquals(2, queryParametersLazyList.sizeCached()); } |
MidaoFactory { public static AsyncQueryRunnerService getAsyncQueryRunner(QueryRunner runner, ExecutorService executorService) { return new AsyncQueryRunner(runner, executorService); } static QueryRunnerService getQueryRunner(DataSource ds); static QueryRunnerService getQueryRunner(DataSource ds, Class<? extends TypeHa... | @Test public void testGetAsyncQueryRunner() throws Exception { Assert.assertEquals(true, MidaoFactory.getAsyncQueryRunner(null, null) instanceof AsyncQueryRunner); } |
QueryParametersLazyList implements List<QueryParameters> { public boolean isEmpty() { boolean result = generatedCacheMap.isEmpty(); return result; } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, TypeHand... | @Test public void testIsEmpty() throws Exception { Assert.assertEquals(false, queryParametersLazyList.isEmpty()); } |
QueryParametersLazyList implements List<QueryParameters> { public int size() { throw new MjdbcRuntimeException("Size is unknown in lazy cache implementation. Please use sizeCached()"); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParam... | @Test(expected = MjdbcRuntimeException.class) public void testSize() throws Exception { queryParametersLazyList.size(); } |
QueryParametersLazyList implements List<QueryParameters> { public int sizeCached() { return generatedCacheMap.size() + resultSetCacheMap.size(); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, TypeHandle... | @Test public void testSizeCached() throws Exception { Assert.assertEquals(1, queryParametersLazyList.sizeCached()); queryParametersLazyList.get(1); queryParametersLazyList.get(2); Assert.assertEquals(3, queryParametersLazyList.sizeCached()); } |
QueryParametersLazyList implements List<QueryParameters> { public Object[] toArray() { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED + " Please use toArrayCached instead."); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLa... | @Test(expected = MjdbcRuntimeException.class) public void testToArray() throws Exception { queryParametersLazyList.toArray(); }
@Test(expected = MjdbcRuntimeException.class) public void testToArrayType() throws Exception { queryParametersLazyList.toArray(new String[0]); } |
QueryParametersLazyList implements List<QueryParameters> { public Object[] toArrayCached() { Object[] readCacheArray = generatedCacheMap.values().toArray(); Object[] writeCacheArray = resultSetCacheMap.values().toArray(); Object[] combinedCacheArray = new Object[readCacheArray.length + writeCacheArray.length]; System.a... | @Test public void testToArrayCached() throws Exception { Object[] result = queryParametersLazyList.toArrayCached(); Assert.assertEquals(1, result.length); queryParametersLazyList.get(1); queryParametersLazyList.get(2); result = queryParametersLazyList.toArrayCached(); Assert.assertEquals(3, result.length); Assert.asser... |
QueryParametersLazyList implements List<QueryParameters> { public List<QueryParameters> subList(int fromIndex, int toIndex) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED + " Please use subListCached instead."); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type... | @Test(expected = MjdbcRuntimeException.class) public void testSubList() throws Exception { queryParametersLazyList.subList(0, 2); } |
QueryParametersLazyList implements List<QueryParameters> { public List<QueryParameters> subListCached(int fromIndex, int toIndex) { ArrayList<QueryParameters> result = new ArrayList<QueryParameters>(); result.addAll(generatedCacheMap.values()); result.addAll(resultSetCacheMap.values()); return result.subList(fromIndex,... | @Test public void testSubListCached() throws Exception { List<QueryParameters> result = null; try { result = queryParametersLazyList.subListCached(1, 3); fail(); } catch (IndexOutOfBoundsException ex) { } queryParametersLazyList.get(1); queryParametersLazyList.get(2); result = queryParametersLazyList.subListCached(1, 3... |
QueryParametersLazyList implements List<QueryParameters> { public QueryParameters get(int index) { if (getCurrentResultSet() == null && index > 0 && valueCached(index) == false) { return null; } QueryParameters params = null; try { if (valueCached(index) == false) { if (this.type == Type.READ_ONLY_FORWARD && currentInd... | @Test public void testGet() throws Exception { Assert.assertEquals("Nightcrawler", queryParametersLazyList.get(1).getValue("name")); Assert.assertEquals("Lobo", queryParametersLazyList.get(2).getValue("name")); Assert.assertEquals(null, queryParametersLazyList.get(3)); } |
QueryParametersLazyList implements List<QueryParameters> { public void close() { while (getCurrentResultSet() != null) { try { closeResultSet(getCurrentResultSet()); setCurrentResultSet(getNextResultSet()); } catch (SQLException ex) { setCurrentResultSet(null); } } MjdbcUtils.closeQuietly(stmt); } QueryParametersLazyLi... | @Test public void testClose() throws Exception { queryParametersLazyList.close(); verify(rs, times(1)).close(); verify(stmt, times(1)).close(); } |
QueryParametersLazyList implements List<QueryParameters> { public Iterator<QueryParameters> iterator() { final QueryParametersLazyList source = this; return new Iterator<QueryParameters>() { private LazyCacheIterator<QueryParameters> lazyCacheIterator = source.getLazyCacheIterator(-1); public boolean hasNext() { return... | @Test public void testIterator() throws Exception { Iterator<QueryParameters> iter = queryParametersLazyList.iterator(); iter.next(); Assert.assertEquals("Nightcrawler", iter.next().getValue("name")); Assert.assertEquals("Lobo", iter.next().getValue("name")); } |
QueryParametersLazyList implements List<QueryParameters> { public QueryParameters set(int index, QueryParameters element) { QueryParameters params = null; if (getMaxCacheSize() != -1) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED + ". Cache update is allowed when Cache is not limited (used by Cached output handle... | @Test public void testSet() throws Exception { QueryParameters paramsOriginal1 = null; QueryParameters paramsOriginal2 = null; QueryParameters paramsSet = new QueryParameters(); paramsOriginal1 = queryParametersLazyList.get(1); paramsOriginal2 = queryParametersLazyList.set(1, paramsSet); Assert.assertEquals(paramsOrigi... |
QueryParametersLazyList implements List<QueryParameters> { public ListIterator<QueryParameters> listIterator() { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED + " Please use iterator() instead."); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSi... | @Test(expected = MjdbcRuntimeException.class) public void testListIterator() throws Exception { queryParametersLazyList.listIterator(); }
@Test(expected = MjdbcRuntimeException.class) public void testListIteratorIndex() throws Exception { queryParametersLazyList.listIterator(1); } |
QueryParametersLazyList implements List<QueryParameters> { public boolean add(QueryParameters queryParameters) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statem... | @Test(expected = MjdbcRuntimeException.class) public void testAdd() throws Exception { queryParametersLazyList.add(null); }
@Test(expected = MjdbcRuntimeException.class) public void testAddIndex() throws Exception { queryParametersLazyList.add(1, null); } |
QueryParametersLazyList implements List<QueryParameters> { public boolean addAll(Collection<? extends QueryParameters> c) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazy... | @Test(expected = MjdbcRuntimeException.class) public void testAddAll() throws Exception { queryParametersLazyList.addAll(Arrays.<QueryParameters>asList(new QueryParameters[0])); }
@Test(expected = MjdbcRuntimeException.class) public void testAddAllIndex() throws Exception { queryParametersLazyList.addAll(1, Arrays.<Que... |
QueryParametersLazyList implements List<QueryParameters> { public boolean remove(Object o) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, TypeHandle... | @Test(expected = MjdbcRuntimeException.class) public void testRemove() throws Exception { queryParametersLazyList.remove(null); }
@Test(expected = MjdbcRuntimeException.class) public void testRemoveIndex() throws Exception { queryParametersLazyList.remove(1); } |
QueryParametersLazyList implements List<QueryParameters> { public boolean removeAll(Collection<?> c) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, ... | @Test(expected = MjdbcRuntimeException.class) public void testRemoveAll() throws Exception { queryParametersLazyList.removeAll(Arrays.<QueryParameters>asList(new QueryParameters[0])); } |
QueryParametersLazyList implements List<QueryParameters> { public boolean retainAll(Collection<?> c) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, ... | @Test(expected = MjdbcRuntimeException.class) public void testRetainAll() throws Exception { queryParametersLazyList.retainAll(Arrays.<QueryParameters>asList(new QueryParameters[0])); } |
QueryParametersLazyList implements List<QueryParameters> { public void clear() { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, TypeHandler typeHandle... | @Test(expected = MjdbcRuntimeException.class) public void testClear() throws Exception { queryParametersLazyList.clear(); } |
QueryParametersLazyList implements List<QueryParameters> { public boolean contains(Object o) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, TypeHand... | @Test(expected = MjdbcRuntimeException.class) public void testContains() throws Exception { queryParametersLazyList.contains(null); } |
QueryParametersLazyList implements List<QueryParameters> { public boolean containsAll(Collection<?> c) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt... | @Test(expected = MjdbcRuntimeException.class) public void testContainsAll() throws Exception { queryParametersLazyList.containsAll(Arrays.<QueryParameters>asList(new QueryParameters[0])); } |
QueryParametersLazyList implements List<QueryParameters> { public int indexOf(Object o) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, TypeHandler t... | @Test(expected = MjdbcRuntimeException.class) public void testIndexOf() throws Exception { queryParametersLazyList.indexOf(null); } |
QueryParametersLazyList implements List<QueryParameters> { public int lastIndexOf(Object o) { throw new MjdbcRuntimeException(ERROR_NOT_ALLOWED); } QueryParametersLazyList(Statement stmt, TypeHandler typeHandler, boolean readGeneratedKeys, Type type, int maxCacheSize); QueryParametersLazyList(Statement stmt, TypeHandl... | @Test(expected = MjdbcRuntimeException.class) public void testLastIndexOf() throws Exception { queryParametersLazyList.lastIndexOf(null); } |
DefaultCallAdapterFactory extends CallAdapter.Factory { @Override public CallAdapter<?, ?> get(@Nonnull final Type returnType, @Nonnull final Annotation[] annotations, @Nonnull final Retrofit retrofit) { if (getRawType(returnType) != CompletableFuture.class) { return null; } if (!(returnType instanceof ParameterizedTyp... | @Test public void testCreateAdapter() { DefaultCallAdapterFactory factory = new DefaultCallAdapterFactory(false, LOGGER); Type returnType = new ParameterizedType() { @Override public Type[] getActualTypeArguments() { return new Type[]{String.class}; } @Override public Type getRawType() { return CompletableFuture.class;... |
NoOpBotUpdateProcessor implements BotUpdateProcessor { @Override public boolean handleUpdate(@Nonnull final Update update) { return true; } static NoOpBotUpdateProcessor getDefault(); @Override boolean handleUpdate(@Nonnull final Update update); } | @Test public void testMockUpdate() { final BotUpdateProcessor processor = new NoOpBotUpdateProcessor(); final boolean handled = processor.handleUpdate(Mockito.mock(Update.class)); assertTrue(handled); }
@Test public void testHandleNullUpdate() { final BotUpdateProcessor processor = new NoOpBotUpdateProcessor(); final b... |
SteadyBackOff implements BackOff { public final long getInterval() { return interval; } SteadyBackOff(final long interval); static SteadyBackOff newInstance(); @Override long getNextBackOffInMilli(); @Override void reset(); final long getInterval(); static final long DEFAULT_INTERVAL_IN_MILLI; } | @Test public void testGetInterval() { final long interval = new Random().nextInt(1000) + 1; SteadyBackOff backOff = new SteadyBackOff(interval); assertEquals(interval, backOff.getInterval()); int round = new Random().nextInt(100) + 1; while (round > 0) { assertEquals(interval, backOff.getNextBackOffInMilli()); round--;... |
CommandUtil { public static Command parseCommandFromText(final String text) { if (isNullOrEmpty(text) || !text.startsWith(CMD_PREFIX)) { return null; } String[] tmp = text.split(" ", 2); String argument = tmp.length > 1 ? tmp[1] : null; String cmdToBot = tmp[0].replaceFirst(CMD_PREFIX, ""); if (!CMD_PATTERN.matcher(cmd... | @Test public void testParseCommand() { Command cmd; cmd = parseCommandFromText(null); assertNull(cmd); cmd = parseCommandFromText("\n"); assertNull(cmd); cmd = parseCommandFromText(" assertNull(cmd); cmd = parseCommandFromText("/ "); assertNull(cmd); cmd = parseCommandFromText("/ /aaa"); assertNull(cmd); cmd = parseCom... |
CompletableFutureBasedCallAdapter implements CallAdapter<ApiResponse<T>, CompletableFuture<T>> { @Nonnull @Override public CompletableFuture<T> adapt(@Nonnull final Call<ApiResponse<T>> call) { final CompletableFuture<T> fut = new CompletableFuture<T>() { @Override public boolean cancel(final boolean mayInterruptIfRunn... | @Test public void testAdapt() { Type returnType = new ParameterizedType() { @Override public Type[] getActualTypeArguments() { return new Type[]{String.class}; } @Override public Type getRawType() { return CompletableFuture.class; } @Override public Type getOwnerType() { return Object.class; } }; CompletableFutureBased... |
FixedBackOff implements BackOff { @Override public BackOffHandler start() { return new FixedBackOffHandler(); } private FixedBackOff(); FixedBackOff(@Nullable final Long internal, @Nullable final Long maxElapsedTime); static FixedBackOff getDefault(); @Override BackOffHandler start(); long getInterval(); @Override lo... | @Test public void testCustomization() { final long interval = 10; BackOffHandler handler = new FixedBackOff(interval, 100L).start(); for (int i = 1; i <= 11; i++) { if (i <= 10) { assertEquals(interval, handler.nextBackOff()); } else { assertEquals(STOP, handler.nextBackOff()); } } } |
ExponentialBackOff implements BackOff { @Override public BackOffHandler start() { return new ExponentialBackOffHandler(); } private ExponentialBackOff(); ExponentialBackOff(
@Nullable final Long initialInterval,
@Nullable final Double multiplier,
@Nullable final Long maxInterval,
... | @Test public void testCustomization() { long interval = 1; final double multiplier = 2.0; final long maxInterval = 32; BackOffHandler handler = new ExponentialBackOff(1L, multiplier, maxInterval, 128L).start(); for (int i = 1; i <= 12; i++) { if (i <= 6) { assertEquals(interval, handler.nextBackOff()); interval *= mult... |
TelegramUtils { public static void verifyToken(final String token) { checkArgument(!isNullOrEmpty(token), "Token can not be null or empty string!"); if (!TOKEN_PATTERN.matcher(token).matches()) { throw new IllegalArgumentException("Invalid token: " + token); } } static void verifyToken(final String token); static Stri... | @Test public void testVerifyToken() { try { verifyToken(null); fail(); } catch (IllegalArgumentException e) { } try { verifyToken("\n"); fail(); } catch (IllegalArgumentException e) { } try { verifyToken(":"); fail(); } catch (IllegalArgumentException e) { } try { verifyToken(":aa"); fail(); } catch (IllegalArgumentExc... |
TelegramUtils { public static String parseBotIdFromToken(final String token) { verifyToken(token); return token.split(":", 2)[0]; } static void verifyToken(final String token); static String parseBotIdFromToken(final String token); } | @Test public void testParseBotIdFromToken() { assertEquals("000", parseBotIdFromToken("000:bb")); } |
LogOnlyBotUpdateProcessor implements BotUpdateProcessor { @Override public boolean handleUpdate(@Nonnull final Update update) { logger.info(JsonUtil.toJson(update)); return true; } LogOnlyBotUpdateProcessor(@Nonnull final Logger logger); @Override boolean handleUpdate(@Nonnull final Update update); } | @Test public void testMockUpdate() { final BotUpdateProcessor processor = new LogOnlyBotUpdateProcessor(mockLogger); final boolean handled = processor.handleUpdate(Mockito.mock(Update.class)); assertTrue(handled); verify(mockLogger, times(1)).info(anyString()); } |
Colors { public static void setTheme(@NonNull PrimaryColor primaryColor, @NonNull AccentColor accentColor) { setTheme(new ColorTheme(primaryColor, accentColor)); } private Colors(); static void theme(Activity activity); static void theme(Activity activity, @Nullable String taskName,
@Nulla... | @Test(expected = IllegalArgumentException.class) public void testSetThemeThrowsForNullPrimaryColor() { Colors.setTheme(null, AccentColor.AMBER_A200); }
@Test(expected = IllegalArgumentException.class) public void testSetThemeThrowsForNullAccentColor() { Colors.setTheme(PrimaryColor.RED_500, null); }
@Test(expected = Il... |
DigitalOcean { public static void onLoggedIn(String token) { DigitalOcean.authToken = token; if (okHttpClient == null) { OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder() .addInterceptor(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.reque... | @Test public void onLoggedIn() { DigitalOcean.onLoggedIn("m31b5m13b1b23febm1513bj15hb"); } |
FragmentFileSet { public void run() throws IOException { FlatPackageWriterImpl flatPackageWriter = new FlatPackageWriterImpl(0); flatPackageWriter.setDebugOutput(debug); flatPackageWriter.setOutputDirectory(outputDir); Movie movie = new Movie(); for (File input : inputFiles) { System.err.println(input.getAbsolutePath()... | @Test public void testCommandLine() throws IOException { File tmpDir = createTmpDir(); File outputDir = createTmpDir(); copyResource("/smoothstreaming/audio-96000.mp4", tmpDir); copyResource("/smoothstreaming/video-128h-75kbps.mp4", tmpDir); copyResource("/smoothstreaming/video-192h-155kbps.mp4", tmpDir); copyResource(... |
BitReaderBuffer { public int readBits(int i) { byte b = buffer.get(initialPos + position / 8); int v = b < 0 ? b + 256 : b; int left = 8 - position % 8; int rc; if (i <= left) { rc = (v << (position % 8) & 0xFF) >> ((position % 8) + (left - i)); position += i; } else { int now = left; int then = i - left; rc = readBits... | @Test public void testRead_8() { BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(testSequence); Assert.assertEquals(15, bitReaderBuffer.readBits(4)); Assert.assertEquals(15, bitReaderBuffer.readBits(4)); Assert.assertEquals(0, bitReaderBuffer.readBits(4)); Assert.assertEquals(0, bitReaderBuffer.readBits(4)); }
@T... |
BitReaderBuffer { public int remainingBits() { return buffer.limit() * 8 - position; } BitReaderBuffer(ByteBuffer buffer); int readBits(int i); int getPosition(); int byteSync(); int remainingBits(); } | @Test public void testRemainingBits() { BitReaderBuffer bitReaderBuffer = new BitReaderBuffer(testSequence); Assert.assertEquals(32, bitReaderBuffer.remainingBits()); int six = 6; bitReaderBuffer.readBits(six); Assert.assertEquals(32 - six, bitReaderBuffer.remainingBits()); } |
SyncSampleIntersectFinderImpl implements FragmentIntersectionFinder { public long[] sampleNumbers(Track track, Movie movie) { final CacheTuple key = new CacheTuple(track, movie); final long[] result = getSampleNumbersCache.get(key); if (result != null) { return result; } if ("vide".equals(track.getHandler())) { if (tra... | @Test public void testFindSameFrameRate() throws IOException { Movie m = InTestMovieCreator.createMovieOnlyVideo( "/BBB_qpfile_10sec/BBB_fixedres_B_180x320_150.mp4", "/BBB_qpfile_10sec/BBB_fixedres_B_180x320_200.mp4" ); SyncSampleIntersectFinderImpl syncSampleIntersectFinder = new SyncSampleIntersectFinderImpl(); long[... |
SyncSampleIntersectFinderImpl implements FragmentIntersectionFinder { public long[] getCommonIndices(long[] syncSamples, long[] syncSampleTimes, long timeScale, long[]... otherTracksTimes) { List<Long> nuSyncSamples = new LinkedList<Long>(); List<Long> nuSyncSampleTimes = new LinkedList<Long>(); for (int i = 0; i < syn... | @Test public void testGetIndicesToBeRemoved() { SyncSampleIntersectFinderImpl syncSampleIntersectFinder = new SyncSampleIntersectFinderImpl(); long[] a_sample = new long[]{20, 40, 48, 60, 80, 82}; long[] a_times = new long[]{10, 20, 24, 30, 40, 41}; long[] b_1 = new long[]{10, 20, 26, 30, 40}; long[] b_2 = new long[]{1... |
TwoSecondIntersectionFinder implements FragmentIntersectionFinder { public long[] sampleNumbers(Track track, Movie movie) { List<TimeToSampleBox.Entry> entries = track.getDecodingTimeEntries(); double trackLength = 0; for (Track thisTrack : movie.getTracks()) { double thisTracksLength = getDuration(thisTrack) / thisTra... | @Test public void testSampleNumbers() throws Exception { Movie m = MovieCreator.build(Channels.newChannel(TwoSecondIntersectionFinderTest.class.getResourceAsStream("/Beethoven - Bagatelle op.119 no.11 i.m4a"))); TwoSecondIntersectionFinder intersectionFinder = new TwoSecondIntersectionFinder(); long[] s = intersectionF... |
Path { public static Box getPath(Box box, String path) { List<? extends Box> all = getPaths(box, path, true); return all.isEmpty() ? null : all.get(0); } private Path(); static String createPath(Box box); static Box getPath(Box box, String path); static List<Box> getPaths(Box box, String path); static List<Box> getPat... | @Test public void testGetParent() throws Exception { Box b1 = isoFile.getMovieBox().getBoxes(TrackBox.class).get(1).getSampleTableBox().getTimeToSampleBox(); Assert.assertEquals(isoFile.getMovieBox().getBoxes(TrackBox.class).get(1).getSampleTableBox(), Path.getPath(b1, "..")); } |
CroppedTrack extends AbstractTrack { public List<TimeToSampleBox.Entry> getDecodingTimeEntries() { return getDecodingTimeEntries(origTrack.getDecodingTimeEntries(), fromSample, toSample); } CroppedTrack(Track origTrack, long fromSample, long toSample); List<ByteBuffer> getSamples(); SampleDescriptionBox getSampleDescri... | @Test public void testGetDecodingTimeEntries() throws Exception { LinkedList<TimeToSampleBox.Entry> e = new LinkedList<TimeToSampleBox.Entry>(); e.add(new TimeToSampleBox.Entry(2, 3)); e.add(new TimeToSampleBox.Entry(3, 4)); e.add(new TimeToSampleBox.Entry(3, 5)); e.add(new TimeToSampleBox.Entry(2, 6)); List<TimeToSamp... |
CroppedTrack extends AbstractTrack { public List<CompositionTimeToSample.Entry> getCompositionTimeEntries() { return getCompositionTimeEntries(origTrack.getCompositionTimeEntries(), fromSample, toSample); } CroppedTrack(Track origTrack, long fromSample, long toSample); List<ByteBuffer> getSamples(); SampleDescriptionBo... | @Test public void testGetCompositionTimes() throws Exception { LinkedList<CompositionTimeToSample.Entry> e = new LinkedList<CompositionTimeToSample.Entry>(); e.add(new CompositionTimeToSample.Entry(2, 3)); e.add(new CompositionTimeToSample.Entry(3, 4)); e.add(new CompositionTimeToSample.Entry(3, 5)); e.add(new Composit... |
SampleFlags { public void getContent(ByteBuffer os) { BitWriterBuffer bitWriterBuffer = new BitWriterBuffer(os); bitWriterBuffer.writeBits(reserved, 6); bitWriterBuffer.writeBits(sampleDependsOn, 2); bitWriterBuffer.writeBits(sampleIsDependedOn, 2); bitWriterBuffer.writeBits(sampleHasRedundancy, 2); bitWriterBuffer.wri... | @Test public void testSimple() throws IOException { long l = 0x11223344; SampleFlags sf = new SampleFlags(ByteBuffer.wrap(new byte[]{0x11, 0x22, 0x33, 0x44})); ByteBuffer b = ByteBuffer.allocate(4); sf.getContent(b); b.rewind(); Assert.assertEquals(l, IsoTypeReader.readUInt32(b)); } |
SampleDependencyTypeBox extends AbstractFullBox { public void setEntries(List<Entry> entries) { this.entries = entries; } SampleDependencyTypeBox(); @Override void _parseDetails(ByteBuffer content); List<Entry> getEntries(); void setEntries(List<Entry> entries); @Override String toString(); static final String TYPE; } | @Test public void testParse() throws Exception { SampleDependencyTypeBox stsc = new SampleDependencyTypeBox(); List<SampleDependencyTypeBox.Entry> l = new LinkedList<SampleDependencyTypeBox.Entry>(); for (int i = 0; i < 0xcf; i++) { SampleDependencyTypeBox.Entry e = new SampleDependencyTypeBox.Entry(i); l.add(e); } sts... |
SampleList extends AbstractList<ByteBuffer> { @Override public ByteBuffer get(int index) { long offset = offsets[index]; int sampleSize = l2i(sizes[index]); for (MediaDataBox mediaDataBox : mdats) { if ((mediaDataBox.getDataStartPosition() <= offset) && (offset + sampleSize <= mediaDataBox.getDataEndPosition())) { retu... | @Test public void testGotAll() throws IOException { String input = SampleListTest.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/Beethoven - Bagatelle op.119 no.11 i.m4a"; IsoFile isoFile = new IsoFile(input); TrackBox tb = isoFile.getBoxes(MovieBox.class).get(0).getBoxes(TrackBox.class).get(0)... |
IsoTypeReader { public static double readFixedPoint1616(ByteBuffer bb) { byte[] bytes = new byte[4]; bb.get(bytes); int result = 0; result |= ((bytes[0] << 24) & 0xFF000000); result |= ((bytes[1] << 16) & 0xFF0000); result |= ((bytes[2] << 8) & 0xFF00); result |= ((bytes[3]) & 0xFF); return ((double) result) / 65536; }... | @Test public void testFixedPoint1616() throws IOException { final double fixedPointTest1 = 10.13; final double fixedPointTest2 = -10.13; ByteBuffer bb = ByteBuffer.allocate(8); IsoTypeWriter.writeFixedPoint1616(bb, fixedPointTest1); IsoTypeWriter.writeFixedPoint1616(bb, fixedPointTest2); bb.rewind(); Assert.assertEqual... |
IsoTypeReader { public static double readFixedPoint0230(ByteBuffer bb) { byte[] bytes = new byte[4]; bb.get(bytes); int result = 0; result |= ((bytes[0] << 24) & 0xFF000000); result |= ((bytes[1] << 16) & 0xFF0000); result |= ((bytes[2] << 8) & 0xFF00); result |= ((bytes[3]) & 0xFF); return ((double) result) / (1 << 30... | @Test public void testFixedPoint0230() throws IOException { final double fixedPointTest1 = 1.13; final double fixedPointTest2 = -1.13; ByteBuffer bb = ByteBuffer.allocate(8); IsoTypeWriter.writeFixedPoint0230(bb, fixedPointTest1); IsoTypeWriter.writeFixedPoint0230(bb, fixedPointTest2); bb.rewind(); Assert.assertEquals(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.