src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
AsyncProcess { public <CResult> AsyncRequestFuture submitAll(TableName tableName, List<? extends Row> rows, Batch.Callback<CResult> callback, Object[] results) { return submitAll(null, tableName, rows, callback, results); } AsyncProcess(ClusterConnection hc, Configuration conf, ExecutorService pool,
RpcRetryingCa... | @Test public void testReplicaReplicaSuccess() throws Exception { MyAsyncProcessWithReplicas ap = createReplicaAp(10, 1000, 0); List<Get> rows = makeTimelineGets(DUMMY_BYTES_1, DUMMY_BYTES_2, DUMMY_BYTES_3); AsyncRequestFuture ars = ap.submitAll(DUMMY_TABLE, rows, null, new Object[3]); verifyReplicaResult(ars, RR.TRUE, ... |
Get extends Query implements Row, Comparable<Row> { public Get(byte [] row) { Mutation.checkRow(row); this.row = row; } Get(byte [] row); Get(Get get); boolean isCheckExistenceOnly(); Get setCheckExistenceOnly(boolean checkExistenceOnly); boolean isClosestRowBefore(); Get setClosestRowBefore(boolean closestRowBefore);... | @Test public void testDynamicFilter() throws Exception { Configuration conf = HBaseConfiguration.create(); String localPath = conf.get("hbase.local.dir") + File.separator + "jars" + File.separator; File jarFile = new File(localPath, "MockFilter.jar"); jarFile.delete(); assertFalse("Should be deleted: " + jarFile.getPat... |
Operation { public String toJSON(int maxCols) throws IOException { return JsonMapper.writeMapAsString(toMap(maxCols)); } abstract Map<String, Object> getFingerprint(); abstract Map<String, Object> toMap(int maxCols); Map<String, Object> toMap(); String toJSON(int maxCols); String toJSON(); String toString(int maxCols)... | @Test public void testOperationJSON() throws IOException { Scan scan = new Scan(ROW); scan.addColumn(FAMILY, QUALIFIER); String json = scan.toJSON(); Map<String, Object> parsedJSON = mapper.readValue(json, HashMap.class); assertEquals("startRow incorrect in Scan.toJSON()", Bytes.toStringBinary(ROW), parsedJSON.get("sta... |
DelayingRunner implements Runnable { public DelayingRunner(long sleepTime, Map.Entry<byte[], List<Action<T>>> e) { this.sleepTime = sleepTime; add(e); } DelayingRunner(long sleepTime, Map.Entry<byte[], List<Action<T>>> e); void setRunner(Runnable runner); @Override void run(); void add(Map.Entry<byte[], List<Action<T>>... | @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testDelayingRunner() throws Exception{ MultiAction<Row> ma = new MultiAction<Row>(); ma.add(hri1.getRegionName(), new Action<Row>(new Put(DUMMY_BYTES_1), 0)); final AtomicLong endTime = new AtomicLong(); final long sleepTime = 1000; DelayingRunner runner ... |
Scan extends Query { @Override public Scan setAttribute(String name, byte[] value) { return (Scan) super.setAttribute(name, value); } Scan(); Scan(byte [] startRow, Filter filter); Scan(byte [] startRow); Scan(byte [] startRow, byte [] stopRow); Scan(Scan scan); Scan(Get get); boolean isGetScan(); Scan addFamily(b... | @Test public void testAttributesSerialization() throws IOException { Scan scan = new Scan(); scan.setAttribute("attribute1", Bytes.toBytes("value1")); scan.setAttribute("attribute2", Bytes.toBytes("value2")); scan.setAttribute("attribute3", Bytes.toBytes("value3")); ClientProtos.Scan scanProto = ProtobufUtil.toScan(sca... |
Scan extends Query { @Override public Scan setAuthorizations(Authorizations authorizations) { return (Scan) super.setAuthorizations(authorizations); } Scan(); Scan(byte [] startRow, Filter filter); Scan(byte [] startRow); Scan(byte [] startRow, byte [] stopRow); Scan(Scan scan); Scan(Get get); boolean isGetScan();... | @Test public void testSetAuthorizations() { Scan scan = new Scan(); try { scan.setAuthorizations(new Authorizations("\u002b|\u0029")); scan.setAuthorizations(new Authorizations("A", "B", "0123", "A0", "1A1", "_a")); scan.setAuthorizations(new Authorizations("A|B")); scan.setAuthorizations(new Authorizations("A&B")); sc... |
Put extends Mutation implements HeapSize, Comparable<Row> { public Put addColumn(byte [] family, byte [] qualifier, byte [] value) { return addColumn(family, qualifier, this.ts, value); } Put(byte [] row); Put(byte[] row, long ts); Put(byte [] rowArray, int rowOffset, int rowLength); Put(ByteBuffer row, long ts); P... | @Test public void testCopyConstructor() { Put origin = new Put(Bytes.toBytes("ROW-01")); byte[] family = Bytes.toBytes("CF-01"); byte[] qualifier = Bytes.toBytes("Q-01"); origin.addColumn(family, qualifier, Bytes.toBytes("V-01")); Put clone = new Put(origin); assertEquals(origin.getCellList(family), clone.getCellList(f... |
ClientScanner extends AbstractClientScanner { protected void loadCache() throws IOException { Result[] values = null; long remainingResultSize = maxScannerResultSize; int countdown = this.caching; callable.setCaching(this.caching); boolean retryAfterOutOfOrderException = true; boolean serverHasMoreResults = false; bool... | @Test @SuppressWarnings("unchecked") public void testNoResultsHint() throws IOException { final Result[] results = new Result[1]; KeyValue kv1 = new KeyValue("row".getBytes(), "cf".getBytes(), "cq".getBytes(), 1, Type.Maximum); results[0] = Result.create(new Cell[] {kv1}); RpcRetryingCaller<Result[]> caller = Mockito.m... |
ClientScanner extends AbstractClientScanner { @Override public Result next() throws IOException { if (cache.size() == 0 && this.closed) { return null; } if (cache.size() == 0) { loadCache(); } if (cache.size() > 0) { return cache.poll(); } writeScanMetrics(); return null; } ClientScanner(final Configuration conf, final... | @Test (timeout = 30000) public void testExceptionsFromReplicasArePropagated() throws IOException { scan.setConsistency(Consistency.TIMELINE); rpcFactory = new MockRpcRetryingCallerFactory(conf); conf.set(RpcRetryingCallerFactory.CUSTOM_CALLER_CONF_KEY, MockRpcRetryingCallerFactory.class.getName()); when(clusterConn.loc... |
ZKUtil { private static ArrayList<ACL> createACL(ZooKeeperWatcher zkw, String node) { return createACL(zkw, node, isSecureZooKeeper(zkw.getConfiguration())); } static RecoverableZooKeeper connect(Configuration conf, Watcher watcher); static RecoverableZooKeeper connect(Configuration conf, String ensemble,
Watche... | @Test public void testCreateACL() throws ZooKeeperConnectionException, IOException { Configuration conf = HBaseConfiguration.create(); conf.set(Superusers.SUPERUSER_CONF_KEY, "user1,@group1,user2,@group2,user3"); String node = "/hbase/testCreateACL"; ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, node, null, fal... |
ZooKeeperWatcher implements Watcher, Abortable, Closeable { public boolean isClientReadable(String node) { return node.equals(baseZNode) || isAnyMetaReplicaZnode(node) || node.equals(getMasterAddressZNode()) || node.equals(clusterIdZNode)|| node.equals(rsZNode) || node.equals(tableZNode) || node.startsWith(tableZNode +... | @Test public void testIsClientReadable() throws ZooKeeperConnectionException, IOException { ZooKeeperWatcher watcher = new ZooKeeperWatcher(HBaseConfiguration.create(), "testIsClientReadable", null, false); assertTrue(watcher.isClientReadable(watcher.baseZNode)); assertTrue(watcher.isClientReadable(watcher.getZNodeForR... |
HTableDescriptor implements WritableComparable<HTableDescriptor> { public HTableDescriptor addCoprocessor(String className) throws IOException { addCoprocessor(className, null, Coprocessor.PRIORITY_USER, null); return this; } @InterfaceAudience.Private protected HTableDescriptor(final TableName name, HColumnDescriptor... | @Test (expected=IOException.class) public void testAddCoprocessorTwice() throws IOException { HTableDescriptor htd = new HTableDescriptor(TableName.META_TABLE_NAME); String cpName = "a.b.c.d"; htd.addCoprocessor(cpName); htd.addCoprocessor(cpName); } |
HTableDescriptor implements WritableComparable<HTableDescriptor> { public HTableDescriptor addCoprocessorWithSpec(final String specStr) throws IOException { String className = getCoprocessorClassNameFromSpecStr(specStr); if (className == null) { throw new IllegalArgumentException("Format does not match " + HConstants.C... | @Test public void testAddCoprocessorWithSpecStr() throws IOException { HTableDescriptor htd = new HTableDescriptor(TableName.META_TABLE_NAME); String cpName = "a.b.c.d"; boolean expected = false; try { htd.addCoprocessorWithSpec(cpName); } catch (IllegalArgumentException iae) { expected = true; } if (!expected) fail();... |
HTableDescriptor implements WritableComparable<HTableDescriptor> { public String getNameAsString() { return name.getNameAsString(); } @InterfaceAudience.Private protected HTableDescriptor(final TableName name, HColumnDescriptor[] families); protected HTableDescriptor(final TableName name, HColumnDescriptor[] families... | @Test public void testLegalHTableNamesRegex() { for (String tn : legalTableNames) { TableName tName = TableName.valueOf(tn); assertTrue("Testing: '" + tn + "'", Pattern.matches(TableName.VALID_USER_TABLE_REGEX, tName.getNameAsString())); } } |
HTableDescriptor implements WritableComparable<HTableDescriptor> { public long getMaxFileSize() { byte [] value = getValue(MAX_FILESIZE_KEY); if (value != null) { return Long.parseLong(Bytes.toString(value)); } return -1; } @InterfaceAudience.Private protected HTableDescriptor(final TableName name, HColumnDescriptor[]... | @Test public void testGetMaxFileSize() { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("table")); assertEquals(-1, desc.getMaxFileSize()); desc.setMaxFileSize(1111L); assertEquals(1111L, desc.getMaxFileSize()); } |
HTableDescriptor implements WritableComparable<HTableDescriptor> { public long getMemStoreFlushSize() { byte [] value = getValue(MEMSTORE_FLUSHSIZE_KEY); if (value != null) { return Long.parseLong(Bytes.toString(value)); } return -1; } @InterfaceAudience.Private protected HTableDescriptor(final TableName name, HColumn... | @Test public void testGetMemStoreFlushSize() { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("table")); assertEquals(-1, desc.getMemStoreFlushSize()); desc.setMemStoreFlushSize(1111L); assertEquals(1111L, desc.getMemStoreFlushSize()); } |
HTableDescriptor implements WritableComparable<HTableDescriptor> { public HTableDescriptor modifyFamily(final HColumnDescriptor family) { if (family.getName() == null || family.getName().length <= 0) { throw new IllegalArgumentException("Family name cannot be null or empty"); } if (!hasFamily(family.getName())) { throw... | @Test public void testModifyFamily() { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("table")); byte[] familyName = Bytes.toBytes("cf"); HColumnDescriptor hcd = new HColumnDescriptor(familyName); hcd.setBlocksize(1000); hcd.setDFSReplication((short) 3); htd.addFamily(hcd); assertEquals(1000, htd.getFami... |
NamespacesResource extends ResourceBase { @GET @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF, MIMETYPE_PROTOBUF_IETF}) public Response get(final @Context ServletContext context, final @Context UriInfo uriInfo) { if (LOG.isDebugEnabled()) { LOG.debug("GET " + uriInfo.getAbsolutePath()); } serv... | @Test public void testNamespaceListXMLandJSON() throws IOException, JAXBException { String namespacePath = "/namespaces/"; NamespacesModel model; Response response; Admin admin = TEST_UTIL.getHBaseAdmin(); assertFalse(doesNamespaceExist(admin, NAMESPACE1)); model = testNamespacesModel.buildTestModel(); testNamespacesMo... |
HBaseFsck extends Configured implements Closeable { public ErrorReporter getErrors() { return errors; } HBaseFsck(Configuration conf); HBaseFsck(Configuration conf, ExecutorService exec); void connect(); void offlineHdfsIntegrityRepair(); int onlineConsistencyRepair(); int onlineHbck(); static byte[] keyOnly(byte[] b)... | @Test public void testOrphanedTableZNode() throws Exception { TableName table = TableName.valueOf("testOrphanedZKTableEntry"); try { TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().getTableStateManager() .setTableState(table, ZooKeeperProtos.Table.State.ENABLING); try { setupTable(table); Assert.fail( "C... |
HBaseFsck extends Configured implements Closeable { private void deleteMetaRegion(HbckInfo hi) throws IOException { deleteMetaRegion(hi.metaEntry.getRegionName()); } HBaseFsck(Configuration conf); HBaseFsck(Configuration conf, ExecutorService exec); void connect(); void offlineHdfsIntegrityRepair(); int onlineConsiste... | @Test (timeout=180000) public void testMetaOffline() throws Exception { HBaseFsck hbck = doFsck(conf, false); assertNoErrors(hbck); deleteMetaRegion(conf, true, false, false); hbck = doFsck(conf, false); assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.NO_META_REGION, ERROR_CODE.UNKNOWN }); hbck = doFsck(conf, true); a... |
HBaseFsck extends Configured implements Closeable { public void checkRegionBoundaries() { try { ByteArrayComparator comparator = new ByteArrayComparator(); List<HRegionInfo> regions = MetaScanner.listAllRegions(getConf(), connection, false); final RegionBoundariesInformation currentRegionBoundariesInformation = new Reg... | @Test (timeout = 180000) public void testRegionBoundariesCheck() throws Exception { HBaseFsck hbck = doFsck(conf, false); assertNoErrors(hbck); try { hbck.checkRegionBoundaries(); } catch (IllegalArgumentException e) { if (e.getMessage().endsWith("not a valid DFS filename.")) { fail("Table directory path is not valid."... |
IdReadWriteLock { @VisibleForTesting int purgeAndGetEntryPoolSize() { gc(); Threads.sleep(200); lockPool.purge(); return lockPool.size(); } ReentrantReadWriteLock getLock(long id); @VisibleForTesting void waitForWaiters(long id, int numWaiters); } | @Test(timeout = 60000) public void testMultipleClients() throws Exception { ExecutorService exec = Executors.newFixedThreadPool(NUM_THREADS); try { ExecutorCompletionService<Boolean> ecs = new ExecutorCompletionService<Boolean>(exec); for (int i = 0; i < NUM_THREADS; ++i) ecs.submit(new IdLockTestThread("client_" + i))... |
ConnectionCache { ConnectionInfo getCurrentConnection() throws IOException { String userName = getEffectiveUser(); ConnectionInfo connInfo = connections.get(userName); if (connInfo == null || !connInfo.updateAccessTime()) { Lock lock = locker.acquireLock(userName); try { connInfo = connections.get(userName); if (connIn... | @Test public void testConnectionChore() throws Exception { UTIL.startMiniCluster(); ConnectionCache cache = new ConnectionCache(UTIL.getConfiguration(), UserProvider.instantiate(UTIL.getConfiguration()), 1000, 5000); ConnectionCache.ConnectionInfo info = cache.getCurrentConnection(); assertEquals(false, info.connection... |
RegionSizeCalculator { public long getRegionSize(byte[] regionId) { Long size = sizeMap.get(regionId); if (size == null) { LOG.debug("Unknown region:" + Arrays.toString(regionId)); return 0; } else { return size; } } @Deprecated RegionSizeCalculator(HTable table); RegionSizeCalculator(RegionLocator regionLocator, Adm... | @Test public void testLargeRegion() throws Exception { RegionLocator regionLocator = mockRegionLocator("largeRegion"); Admin admin = mockAdmin( mockServer( mockRegion("largeRegion", Integer.MAX_VALUE) ) ); RegionSizeCalculator calculator = new RegionSizeCalculator(regionLocator, admin); assertEquals(((long) Integer.MAX... |
FSVisitor { public static void visitTableStoreFiles(final FileSystem fs, final Path tableDir, final StoreFileVisitor visitor) throws IOException { FileStatus[] regions = FSUtils.listStatus(fs, tableDir, new FSUtils.RegionDirFilter(fs)); if (regions == null) { if (LOG.isTraceEnabled()) { LOG.trace("No regions under dire... | @Test public void testVisitStoreFiles() throws IOException { final Set<String> regions = new HashSet<String>(); final Set<String> families = new HashSet<String>(); final Set<String> hfiles = new HashSet<String>(); FSVisitor.visitTableStoreFiles(fs, tableDir, new FSVisitor.StoreFileVisitor() { public void storeFile(fina... |
FSVisitor { public static void visitTableRecoveredEdits(final FileSystem fs, final Path tableDir, final FSVisitor.RecoveredEditsVisitor visitor) throws IOException { FileStatus[] regions = FSUtils.listStatus(fs, tableDir, new FSUtils.RegionDirFilter(fs)); if (regions == null) { if (LOG.isTraceEnabled()) { LOG.trace("No... | @Test public void testVisitRecoveredEdits() throws IOException { final Set<String> regions = new HashSet<String>(); final Set<String> edits = new HashSet<String>(); FSVisitor.visitTableRecoveredEdits(fs, tableDir, new FSVisitor.RecoveredEditsVisitor() { public void recoveredEdits (final String region, final String logf... |
FSVisitor { public static void visitLogFiles(final FileSystem fs, final Path rootDir, final LogFileVisitor visitor) throws IOException { Path logsDir = new Path(rootDir, HConstants.HREGION_LOGDIR_NAME); FileStatus[] logServerDirs = FSUtils.listStatus(fs, logsDir); if (logServerDirs == null) { if (LOG.isTraceEnabled()) ... | @Test public void testVisitLogFiles() throws IOException { final Set<String> servers = new HashSet<String>(); final Set<String> logs = new HashSet<String>(); FSVisitor.visitLogFiles(fs, rootDir, new FSVisitor.LogFileVisitor() { public void logFile (final String server, final String logfile) throws IOException { servers... |
FSUtils { public static boolean isHDFS(final Configuration conf) throws IOException { FileSystem fs = FileSystem.get(conf); String scheme = fs.getUri().getScheme(); return scheme.equalsIgnoreCase("hdfs"); } protected FSUtils(); static void setStoragePolicy(final FileSystem fs, final Configuration conf,
final Pat... | @Test public void testIsHDFS() throws Exception { HBaseTestingUtility htu = new HBaseTestingUtility(); htu.getConfiguration().setBoolean("dfs.support.append", false); assertFalse(FSUtils.isHDFS(htu.getConfiguration())); htu.getConfiguration().setBoolean("dfs.support.append", true); MiniDFSCluster cluster = null; try { ... |
FSUtils { static public HDFSBlocksDistribution computeHDFSBlocksDistribution( final FileSystem fs, FileStatus status, long start, long length) throws IOException { HDFSBlocksDistribution blocksDistribution = new HDFSBlocksDistribution(); BlockLocation [] blockLocations = fs.getFileBlockLocations(status, start, length);... | @Test public void testcomputeHDFSBlocksDistribution() throws Exception { HBaseTestingUtility htu = new HBaseTestingUtility(); final int DEFAULT_BLOCK_SIZE = 1024; htu.getConfiguration().setLong("dfs.blocksize", DEFAULT_BLOCK_SIZE); MiniDFSCluster cluster = null; Path testFile = null; try { String hosts[] = new String[]... |
FSUtils { public static boolean renameAndSetModifyTime(final FileSystem fs, final Path src, final Path dest) throws IOException { fs.setTimes(src, EnvironmentEdgeManager.currentTime(), -1); return fs.rename(src, dest); } protected FSUtils(); static void setStoragePolicy(final FileSystem fs, final Configuration conf,
... | @Test public void testRenameAndSetModifyTime() throws Exception { HBaseTestingUtility htu = new HBaseTestingUtility(); Configuration conf = htu.getConfiguration(); MiniDFSCluster cluster = htu.startMiniDFSCluster(1); assertTrue(FSUtils.isHDFS(conf)); FileSystem fs = FileSystem.get(conf); Path testDir = htu.getDataTestD... |
FileLink { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (this.getClass().equals(obj.getClass())) { return Arrays.equals(this.locations, ((FileLink) obj).locations); } return false; } protected FileLink(); FileLink(Path originPath, Path... alternativePaths); FileLink(final Colle... | @Test public void testEquals() { Path p1 = new Path("/p1"); Path p2 = new Path("/p2"); Path p3 = new Path("/p3"); assertEquals(new FileLink(), new FileLink()); assertEquals(new FileLink(p1), new FileLink(p1)); assertEquals(new FileLink(p1, p2), new FileLink(p1, p2)); assertEquals(new FileLink(p1, p2, p3), new FileLink(... |
FileLink { @Override public int hashCode() { return Arrays.hashCode(locations); } protected FileLink(); FileLink(Path originPath, Path... alternativePaths); FileLink(final Collection<Path> locations); Path[] getLocations(); @Override String toString(); boolean exists(final FileSystem fs); Path getAvailablePath(FileS... | @Test public void testHashCode() { Path p1 = new Path("/p1"); Path p2 = new Path("/p2"); Path p3 = new Path("/p3"); assertEquals(new FileLink().hashCode(), new FileLink().hashCode()); assertEquals(new FileLink(p1).hashCode(), new FileLink(p1).hashCode()); assertEquals(new FileLink(p1, p2).hashCode(), new FileLink(p1, p... |
FileLink { public FSDataInputStream open(final FileSystem fs) throws IOException { return new FSDataInputStream(new FileLinkInputStream(fs, this)); } protected FileLink(); FileLink(Path originPath, Path... alternativePaths); FileLink(final Collection<Path> locations); Path[] getLocations(); @Override String toString... | @Test public void testHDFSLinkReadDuringDelete() throws Exception { HBaseTestingUtility testUtil = new HBaseTestingUtility(); Configuration conf = testUtil.getConfiguration(); conf.setInt("dfs.blocksize", 1024 * 1024); conf.setInt("dfs.client.read.prefetch.size", 2 * 1024 * 1024); testUtil.startMiniDFSCluster(1); MiniD... |
LruCachedBlock implements HeapSize, Comparable<LruCachedBlock> { @Override public int hashCode() { return (int)(accessTime ^ (accessTime >>> 32)); } LruCachedBlock(BlockCacheKey cacheKey, Cacheable buf, long accessTime); LruCachedBlock(BlockCacheKey cacheKey, Cacheable buf, long accessTime,
boolean inMemory); vo... | @Test public void testEquality() { assertEquals(block.hashCode(), blockEqual.hashCode()); assertNotEquals(block.hashCode(), blockNotEqual.hashCode()); assertEquals(block, blockEqual); assertNotEquals(block, blockNotEqual); } |
BucketCache implements BlockCache, HeapSize { public BucketAllocator getAllocator() { return this.bucketAllocator; } BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
int writerThreadNum, int writerQLen, String persistencePath); BucketCache(String ioEngineName, long capacity, int ... | @Test public void testBucketAllocator() throws BucketAllocatorException { BucketAllocator mAllocator = cache.getAllocator(); final List<Integer> BLOCKSIZES = Arrays.asList(4 * 1024, 8 * 1024, 64 * 1024, 96 * 1024); boolean full = false; ArrayList<Long> allocations = new ArrayList<Long>(); List<Integer> tmp = new ArrayL... |
BucketCache implements BlockCache, HeapSize { void stopWriterThreads() throws InterruptedException { for (WriterThread writerThread : writerThreads) { writerThread.disableWriter(); writerThread.interrupt(); writerThread.join(); } } BucketCache(String ioEngineName, long capacity, int blockSize, int[] bucketSizes,
... | @Test public void testHeapSizeChanges() throws Exception { cache.stopWriterThreads(); CacheTestUtils.testHeapSizeChanges(cache, BLOCK_SIZE); } |
Reference { public static Reference read(final FileSystem fs, final Path p) throws IOException { InputStream in = fs.open(p); try { in = in.markSupported()? in: new BufferedInputStream(in); int pblen = ProtobufUtil.lengthOfPBMagic(); in.mark(pblen); byte [] pbuf = new byte[pblen]; int read = in.read(pbuf); if (read != ... | @Test public void testParsingWritableReference() throws IOException { final String datafile = System.getProperty("test.build.classes", "target/test-classes") + File.separator + "a6a6562b777440fd9c34885428f5cb61.21e75333ada3d5bafb34bb918f29576c"; FileSystem fs = FileSystem.get(HTU.getConfiguration()); Reference.read(fs,... |
MetaMigrationConvertingToPB { static boolean isMetaTableUpdated(final HConnection hConnection) throws IOException { List<Result> results = MetaTableAccessor.fullScanOfMeta(hConnection); if (results == null || results.isEmpty()) { LOG.info("hbase:meta doesn't have any entries to update."); return true; } for (Result r :... | @Test public void testMetaUpdatedFlagInROOT() throws Exception { HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster(); boolean metaUpdated = MetaMigrationConvertingToPB. isMetaTableUpdated(master.getConnection()); assertEquals(true, metaUpdated); verifyMetaRowsAreUpdated(master.getConnection()); } |
LocalHBaseCluster { public LocalHBaseCluster(final Configuration conf) throws IOException { this(conf, DEFAULT_NO); } LocalHBaseCluster(final Configuration conf); LocalHBaseCluster(final Configuration conf, final int noRegionServers); LocalHBaseCluster(final Configuration conf, final int noMasters,
final int no... | @Test public void testLocalHBaseCluster() throws Exception { TEST_UTIL.startMiniCluster(1, 1, null, MyHMaster.class, MyHRegionServer.class); try { int val = ((MyHMaster)TEST_UTIL.getHBaseCluster().getMaster(0)).echo(42); assertEquals(42, val); } catch (ClassCastException e) { fail("Could not cast master to our class");... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> c, HTableDescriptor desc, HRegionInfo[] regions) throws ... | @Test (timeout=180000) public void testTableCreate() throws Exception { AccessTestAction createTable = new AccessTestAction() { @Override public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("testnewtable")); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); ACCESS_CONTR... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, HTableDescriptor htd) throws IOE... | @Test (timeout=180000) public void testTableModify() throws Exception { AccessTestAction modifyTable = new AccessTestAction() { @Override public Object run() throws Exception { HTableDescriptor htd = new HTableDescriptor(TEST_TABLE); htd.addFamily(new HColumnDescriptor(TEST_FAMILY)); htd.addFamily(new HColumnDescriptor... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preDeleteTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName) throws IOException { requirePerm... | @Test (timeout=180000) public void testTableDelete() throws Exception { AccessTestAction deleteTable = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER .preDeleteTable(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE); return null; } }; verifyAllowed(deleteTable, SUP... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preTruncateTable(ObserverContext<MasterCoprocessorEnvironment> c, final TableName tableName) throws IOException { req... | @Test (timeout=180000) public void testTableTruncate() throws Exception { AccessTestAction truncateTable = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER .preTruncateTable(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE); return null; } }; verifyAllowed(truncateTa... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, HColumnDescriptor column) throws I... | @Test (timeout=180000) public void testAddColumn() throws Exception { final HColumnDescriptor hcd = new HColumnDescriptor("fam_new"); AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preAddColumn(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TA... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preModifyColumn(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, HColumnDescriptor descriptor) t... | @Test (timeout=180000) public void testModifyColumn() throws Exception { final HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY); hcd.setMaxVersions(10); AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preModifyColumn(ObserverContext.createA... |
LogLevel { public static void main(String[] args) { if (args.length == 3 && "-getlevel".equals(args[0])) { process("http: return; } else if (args.length == 4 && "-setlevel".equals(args[0])) { process("http: + "&level=" + args[3]); return; } System.err.println(USAGES); System.exit(-1); } static void main(String[] args)... | @Test (timeout=60000) @SuppressWarnings("deprecation") public void testDynamicLogLevel() throws Exception { String logName = TestLogLevel.class.getName(); Log testlog = LogFactory.getLog(logName); if (testlog instanceof Log4JLogger) { Logger log = ((Log4JLogger)testlog).getLogger(); log.debug("log.debug1"); log.info("l... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preDeleteColumn(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, byte[] col) throws IOException ... | @Test (timeout=180000) public void testDeleteColumn() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preDeleteColumn(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE, TEST_FAMILY); return null; } }; verifyAllowed(action,... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preDisableTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName) throws IOException { if (Bytes.... | @Test (timeout=180000) public void testTableDisable() throws Exception { AccessTestAction disableTable = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preDisableTable(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE); return null; } }; AccessTestAction disableAclT... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preEnableTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName) throws IOException { requirePerm... | @Test (timeout=180000) public void testTableEnable() throws Exception { AccessTestAction enableTable = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER .preEnableTable(ObserverContext.createAndPrepare(CP_ENV, null), TEST_TABLE); return null; } }; verifyAllowed(enableTable, SUP... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preAbortProcedure( ObserverContext<MasterCoprocessorEnvironment> ctx, final ProcedureExecutor<MasterProcedureEnv> pro... | @Test public void testAbortProcedure() throws Exception { final TableName tableName = TableName.valueOf("testAbortProcedure"); final ProcedureExecutor<MasterProcedureEnv> procExec = TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor(); Procedure proc = new TestTableDDLProcedure(procExec.getEnvironment()... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void postListProcedures( ObserverContext<MasterCoprocessorEnvironment> ctx, List<ProcedureInfo> procInfoList) throws IOExc... | @Test public void testListProcedures() throws Exception { final TableName tableName = TableName.valueOf("testAbortProcedure"); final ProcedureExecutor<MasterProcedureEnv> procExec = TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor(); Procedure proc = new TestTableDDLProcedure(procExec.getEnvironment()... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preMove(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo region, ServerName srcServer, ServerName destSer... | @Test (timeout=180000) public void testMove() throws Exception { List<HRegionLocation> regions; try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) { regions = locator.getAllRegionLocations(); } HRegionLocation location = regions.get(0); final HRegionInfo hri = location.getRegionInfo(); fina... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preAssign(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo regionInfo) throws IOException { requirePermis... | @Test (timeout=180000) public void testAssign() throws Exception { List<HRegionLocation> regions; try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) { regions = locator.getAllRegionLocations(); } HRegionLocation location = regions.get(0); final HRegionInfo hri = location.getRegionInfo(); Ac... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preUnassign(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo regionInfo, boolean force) throws IOExceptio... | @Test (timeout=180000) public void testUnassign() throws Exception { List<HRegionLocation> regions; try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) { regions = locator.getAllRegionLocations(); } HRegionLocation location = regions.get(0); final HRegionInfo hri = location.getRegionInfo(); ... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preRegionOffline(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo regionInfo) throws IOException { requir... | @Test (timeout=180000) public void testRegionOffline() throws Exception { List<HRegionLocation> regions; try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) { regions = locator.getAllRegionLocations(); } HRegionLocation location = regions.get(0); final HRegionInfo hri = location.getRegionInf... |
AccessController extends BaseMasterAndRegionObserver implements RegionServerObserver,
AccessControlService.Interface, CoprocessorService, EndpointObserver, BulkLoadObserver { @Override public void preBalance(ObserverContext<MasterCoprocessorEnvironment> c) throws IOException { requirePermission("balance", Action.... | @Test (timeout=180000) public void testBalance() throws Exception { AccessTestAction action = new AccessTestAction() { @Override public Object run() throws Exception { ACCESS_CONTROLLER.preBalance(ObserverContext.createAndPrepare(CP_ENV, null)); return null; } }; verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_... |
WsImportMojo extends AbstractJaxwsMojo { static String getActiveHttpProxy(Settings s) { String retVal = null; for (Proxy p : s.getProxies()) { if (p.isActive() && "http".equals(p.getProtocol())) { StringBuilder sb = new StringBuilder(); String user = p.getUsername(); String pwd = p.getPassword(); if (user != null) { sb... | @Test public void testGetActiveHttpProxy() throws IOException, XmlPullParserException { SettingsXpp3Reader r = new SettingsXpp3Reader(); Settings s = r.read(WsImportMojoTest.class.getResourceAsStream("proxy1.xml")); String proxyString = WsImportMojo.getActiveHttpProxy(s); Assert.assertEquals(proxyString, "proxyActive:8... |
TracingHttpClientBuilder extends HttpClientBuilder { public TracingHttpClientBuilder disableInjection() { this.injectDisabled = true; return this; } TracingHttpClientBuilder(); TracingHttpClientBuilder(
RedirectStrategy redirectStrategy,
boolean redirectHandlingDisabled); TracingHttpClientBuilder(
... | @Test public void testDisablePropagation() throws IOException { { HttpClient client = ((TracingHttpClientBuilder)clientBuilder).disableInjection().build(); client.execute(new HttpGet(serverUrl(RedirectHandler.MAPPING))); } List<MockSpan> mockSpans = mockTracer.finishedSpans(); Assert.assertEquals(3, mockSpans.size()); ... |
WXBizMsgCrypt { public String encrypt(String randomStr, String text) throws AesException { ByteGroup byteCollector = new ByteGroup(); byte[] randomStrBytes = randomStr.getBytes(CHARSET); byte[] textBytes = text.getBytes(CHARSET); byte[] networkBytesOrder = getNetworkBytesOrder(textBytes.length); byte[] appidBytes = app... | @Test public void testAesEncrypt() { try { WXBizMsgCrypt pc = new WXBizMsgCrypt(token, encodingAesKey, appId); assertEquals(afterAesEncrypt, pc.encrypt(randomStr, replyMsg)); } catch (AesException e) { e.printStackTrace(); fail("no异常"); } }
@Test public void testAesEncrypt2() { try { WXBizMsgCrypt pc = new WXBizMsgCryp... |
WXBizMsgCrypt { public String verifyUrl(String msgSignature, String timeStamp, String nonce, String echoStr) throws AesException { String signature = SHA1.getSHA1(token, timeStamp, nonce, echoStr); if (!signature.equals(msgSignature)) { throw new AesException(AesException.ValidateSignatureError); } String result = decr... | @Test public void testVerifyUrl() throws AesException { WXBizMsgCrypt wxcpt = new WXBizMsgCrypt("QDG6eK", "jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C", "wx5823bf96d3bd56c7"); String verifyMsgSig = "5c45ff5e21c57e6ad56bac8758b79b1d9ac89fd3"; String timeStamp = "1409659589"; String nonce = "263014780"; String echoStr = ... |
MainActivityPresenter implements MainActivityContract.Presenter { @VisibleForTesting void checkAndroidVersionCompatibility() { if (!supportedByArtist()) { mView.showIncompatibleAndroidVersionDialog(); } } MainActivityPresenter(MainActivityContract.View view,
SettingsManager settingsManager, Co... | @Test public void incompatibilityTest() throws Exception { setFinalStatic(Build.VERSION.class.getField("SDK_INT"), Build.VERSION_CODES.LOLLIPOP); mPresenter.checkAndroidVersionCompatibility(); verify(mView).showIncompatibleAndroidVersionDialog(); }
@Test public void compatibilityTest() throws Exception { setFinalStatic... |
MainActivityPresenter implements MainActivityContract.Presenter { @Override public void selectFragment(@selectableFragment int id) { Fragment selectedFragment = null; switch (id) { case INFO_FRAGMENT: if (mInfoFragment == null) { mInfoFragment = new InfoFragment(); } selectedFragment = mInfoFragment; break; case INSTRU... | @Test public void selectInfoFragment() throws Exception { mPresenter.selectFragment(MainActivityPresenter.INFO_FRAGMENT); verify(mView).showSelectedFragment(mArgumentCaptor.capture()); assertTrue(mArgumentCaptor.getValue() instanceof InfoFragment); }
@Test public void selectAppListFragment() throws Exception { mPresent... |
POP3Store extends Store { @Override public synchronized boolean isConnected() { if (!super.isConnected()) return false; try { if (port == null) port = getPort(null); else if (!port.noop()) throw new IOException("NOOP failed"); return true; } catch (IOException ioex) { try { super.close(); } catch (MessagingException me... | @Test public void testIsConnected() { TestServer server = null; try { final POP3Handler handler = new POP3HandlerNoopErr(); server = new TestServer(handler); server.start(); final Properties properties = new Properties(); properties.setProperty("mail.pop3.host", "localhost"); properties.setProperty("mail.pop3.port", ""... |
SeverityComparator implements Comparator<LogRecord>, Serializable { private static String toString(final Object o1, final Object o2) { return o1 + ", " + o2; } Throwable apply(final Throwable chain); final int applyThenCompare(Throwable tc1, Throwable tc2); int compareThrowable(final Throwable t1, final Throwable t2);... | @Test public void testByNullAndFrameworkInterrupted() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(this.headWidChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1... |
PropUtil { @Deprecated public static int getIntSessionProperty(Session session, String name, int def) { return getInt(getProp(session.getProperties(), name), def); } private PropUtil(); static int getIntProperty(Properties props, String name, int def); static boolean getBooleanProperty(Properties props,
String nam... | @Test @SuppressWarnings("deprecation") public void testSessionIntDef() throws Exception { Properties props = new Properties(); Session sess = Session.getInstance(props, null); assertEquals(PropUtil.getIntSessionProperty(sess, "test", 1), 1); }
@Test @SuppressWarnings("deprecation") public void testSessionIntDefProp() t... |
SeverityComparator implements Comparator<LogRecord>, Serializable { @Override public boolean equals(final Object o) { return o == null ? false : o.getClass() == getClass(); } Throwable apply(final Throwable chain); final int applyThenCompare(Throwable tc1, Throwable tc2); int compareThrowable(final Throwable t1, final... | @Test @SuppressWarnings("ObjectEqualsNull") public void testEquals() { final SeverityComparator a = new SeverityComparator(); final SeverityComparator b = new SeverityComparator(); assertNotSame(a, b); assertNotNull(a); assertFalse(a.equals(null)); assertNotNull(b); assertFalse(b.equals(null)); assertTrue(a.equals(a));... |
SeverityComparator implements Comparator<LogRecord>, Serializable { @Override public int hashCode() { return 31 * getClass().hashCode(); } Throwable apply(final Throwable chain); final int applyThenCompare(Throwable tc1, Throwable tc2); int compareThrowable(final Throwable t1, final Throwable t2); @SuppressWarnings("o... | @Test public void testHashCode() { final SeverityComparator a = new SeverityComparator(); final SeverityComparator b = new SeverityComparator(); assertNotSame(a, b); assertTrue(a.equals(b)); assertTrue(b.equals(a)); assertEquals(a.hashCode(), b.hashCode()); } |
CompactFormatter extends java.util.logging.Formatter { @Override public String format(final LogRecord record) { ResourceBundle rb = record.getResourceBundle(); Locale l = rb == null ? null : rb.getLocale(); String msg = formatMessage(record); String thrown = formatThrown(record); String err = formatError(record); Objec... | @Test public void testFormat() throws Exception { final String p = CompactFormatter.class.getName(); Properties props = new Properties(); props.put(p.concat(".format"), "%9$s"); LogManager manager = LogManager.getLogManager(); try { read(manager, props); CompactFormatter cf = new CompactFormatter(); LogRecord first = n... |
CompactFormatter extends java.util.logging.Formatter { @Override public String formatMessage(final LogRecord record) { String msg = super.formatMessage(record); msg = replaceClassName(msg, record.getThrown()); msg = replaceClassName(msg, record.getParameters()); return msg; } CompactFormatter(); CompactFormatter(final... | @Test(expected = NullPointerException.class) public void testFormatMessageNull() { CompactFormatter cf = new CompactFormatter(); cf.formatMessage((LogRecord) null); fail(cf.toString()); }
@Test(timeout = 30000) public void testFormatMessage_LogRecordEvil() { LogRecord record = new LogRecord(Level.SEVERE, ""); record.se... |
PropUtil { @Deprecated public static boolean getBooleanSessionProperty(Session session, String name, boolean def) { return getBoolean(getProp(session.getProperties(), name), def); } private PropUtil(); static int getIntProperty(Properties props, String name, int def); static boolean getBooleanProperty(Properties props... | @Test @SuppressWarnings("deprecation") public void testSessionBool() throws Exception { Properties props = new Properties(); props.setProperty("test", "true"); Session sess = Session.getInstance(props, null); assertTrue(PropUtil.getBooleanSessionProperty(sess, "test", false)); }
@Test @SuppressWarnings("deprecation") p... |
CompactFormatter extends java.util.logging.Formatter { public String formatLevel(final LogRecord record) { return record.getLevel().getLocalizedName(); } CompactFormatter(); CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord record); S... | @Test public void testFormatLevel() { CompactFormatter cf = new CompactFormatter(); LogRecord record = new LogRecord(Level.SEVERE, ""); String result = cf.formatLevel(record); assertEquals(record.getLevel().getLocalizedName(), result); }
@Test(expected = NullPointerException.class) public void testFormatLevelNull() { C... |
CompactFormatter extends java.util.logging.Formatter { public String formatLoggerName(final LogRecord record) { return simpleClassName(record.getLoggerName()); } CompactFormatter(); CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord re... | @Test public void testFormatLogger() { CompactFormatter cf = new CompactFormatter(); LogRecord record = new LogRecord(Level.SEVERE, ""); record.setSourceMethodName(null); record.setSourceClassName(null); record.setLoggerName(Object.class.getName()); String result = cf.formatLoggerName(record); assertEquals(Object.class... |
CompactFormatter extends java.util.logging.Formatter { public String formatSource(final LogRecord record) { String source = record.getSourceClassName(); if (source != null) { if (record.getSourceMethodName() != null) { source = simpleClassName(source) + " " + record.getSourceMethodName(); } else { source = simpleClassN... | @Test public void testFormatSourceByLogger() { CompactFormatter cf = new CompactFormatter(); LogRecord record = new LogRecord(Level.SEVERE, ""); record.setSourceMethodName(null); record.setSourceClassName(null); record.setLoggerName(Object.class.getName()); String result = cf.formatSource(record); assertEquals(Object.c... |
CompactFormatter extends java.util.logging.Formatter { public String formatThrown(final LogRecord record) { String msg; final Throwable t = record.getThrown(); if (t != null) { String site = formatBackTrace(record); msg = formatMessage(t) + (isNullOrSpaces(site) ? "" : ' ' + site); } else { msg = ""; } return msg; } Co... | @Test(timeout = 30000) public void testFormatThrownEvilThrown() { LogRecord record = new LogRecord(Level.SEVERE, ""); record.setThrown(createEvilThrowable()); CompactFormatter cf = new CompactFormatter(); cf.formatThrown(record); }
@Test public void testFormatThrown() { Exception e = new IOException("Fake I/O"); e = ne... |
CompactFormatter extends java.util.logging.Formatter { public Number formatThreadID(final LogRecord record) { return (((long) record.getThreadID()) & 0xffffffffL); } CompactFormatter(); CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecor... | @Test public void testFormatThreadID() { CompactFormatter cf = new CompactFormatter("%10$d"); LogRecord record = new LogRecord(Level.SEVERE, ""); record.setThreadID(10); String output = cf.format(record); String expect = Long.toString(record.getThreadID()); assertEquals(expect, output); record.setThreadID(-1); output =... |
CompactFormatter extends java.util.logging.Formatter { public String formatError(final LogRecord record) { return formatMessage(record.getThrown()); } CompactFormatter(); CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord record); Stri... | @Test public void testFormatError() { CompactFormatter cf = new CompactFormatter("%11$s"); LogRecord record = new LogRecord(Level.SEVERE, "message"); record.setThrown(new Throwable("error")); String output = cf.format(record); assertTrue(output.startsWith(record.getThrown() .getClass().getSimpleName())); assertTrue(out... |
PropUtil { public static boolean getBooleanSystemProperty(String name, boolean def) { try { return getBoolean(getProp(System.getProperties(), name), def); } catch (SecurityException sex) { } try { String value = System.getProperty(name); if (value == null) return def; if (def) return !value.equalsIgnoreCase("false"); e... | @Test public void testSystemBool() throws Exception { System.setProperty("test", "true"); assertTrue(PropUtil.getBooleanSystemProperty("test", false)); }
@Test public void testSystemBoolDef() throws Exception { assertTrue(PropUtil.getBooleanSystemProperty("testnotset", true)); }
@Test public void testSystemBoolean() th... |
CompactFormatter extends java.util.logging.Formatter { public String formatBackTrace(final LogRecord record) { String site = ""; final Throwable t = record.getThrown(); if (t != null) { final Throwable root = apply(t); StackTraceElement[] trace = root.getStackTrace(); site = findAndFormat(trace); if (isNullOrSpaces(sit... | @Test public void testFormatBackTrace() { Exception e = new IOException("Fake I/O"); e = new Exception(e.toString(), e); assertNotNull(e.getMessage(), e.getMessage()); CompactFormatter cf = new CompactFormatter("%14$s"); LogRecord record = new LogRecord(Level.SEVERE, ""); record.setThrown(e); String result = cf.formatB... |
CompactFormatter extends java.util.logging.Formatter { protected Throwable apply(final Throwable t) { return SeverityComparator.getInstance().apply(t); } CompactFormatter(); CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord record); S... | @Test public void testApply() { CompactFormatter cf = new CompactFormatter(); assertNull(cf.apply((Throwable) null)); final Throwable t = new Throwable(); Throwable e = cf.apply(t); assertSame(t, e); }
@Test public void testApplyNull() { assertNull(new CompactFormatter().apply(null)); }
@Test(timeout = 30000) public vo... |
CompactFormatter extends java.util.logging.Formatter { protected boolean ignore(final StackTraceElement s) { return isUnknown(s) || defaultIgnore(s); } CompactFormatter(); CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final LogRecord record); Str... | @Test(expected = NullPointerException.class) public void testIgnoreNull() { CompactFormatter cf = new CompactFormatter(); cf.ignore((StackTraceElement) null); fail(cf.toString()); }
@Test public void testIgnoreKnownClass() { CompactFormatter cf = new CompactFormatter(); String n = cf.getClass().getName(); String f = n.... |
PropUtil { public static int getIntProperty(Properties props, String name, int def) { return getInt(getProp(props, name), def); } private PropUtil(); static int getIntProperty(Properties props, String name, int def); static boolean getBooleanProperty(Properties props,
String name, boolean def); @Deprecated static ... | @Test public void testInt() throws Exception { Properties props = new Properties(); props.setProperty("test", "2"); assertEquals(PropUtil.getIntProperty(props, "test", 1), 2); }
@Test public void testIntDef() throws Exception { Properties props = new Properties(); assertEquals(PropUtil.getIntProperty(props, "test", 1),... |
CompactFormatter extends java.util.logging.Formatter { protected String toAlternate(final String s) { return s != null ? s.replaceAll("[\\x00-\\x1F\\x7F]+", "") : null; } CompactFormatter(); CompactFormatter(final String format); @Override String format(final LogRecord record); @Override String formatMessage(final Log... | @Test public void testToAlternate() { CompactFormatter cf = new CompactFormatter(); assertEquals("", cf.toAlternate(LINE_SEP)); }
@Test public void testToAlternateNull() { CompactFormatter cf = new CompactFormatter(); assertNull(cf.toAlternate((String) null)); } |
CollectorFormatter extends Formatter { @Override public String toString() { String result; try { result = formatRecord((Handler) null, false); } catch (final RuntimeException ignore) { result = super.toString(); } return result; } CollectorFormatter(); CollectorFormatter(String format); CollectorFormatter(String form... | @Test public void testDeclaredClasses() throws Exception { Class<?>[] declared = CollectorFormatter.class.getDeclaredClasses(); assertEquals(Arrays.toString(declared), 0, declared.length); } |
LogManagerProperties extends Properties { static void checkLogManagerAccess() { boolean checked = false; final Object m = LOG_MANAGER; if (m != null) { try { if (m instanceof LogManager) { checked = true; ((LogManager) m).checkAccess(); } } catch (final SecurityException notAllowed) { if (checked) { throw notAllowed; }... | @Test public void testCheckAccessPresent() { LogManager m = LogManager.getLogManager(); m.checkAccess(); LogManagerProperties.checkLogManagerAccess(); LogPermSecurityManager sm = new LogPermSecurityManager(); sm.secure = false; System.setSecurityManager(sm); try { sm.secure = true; try { m.checkAccess(); fail(m.toStrin... |
CollectorFormatter extends Formatter { @Override public String format(final LogRecord record) { if (record == null) { throw new NullPointerException(); } boolean accepted; do { final LogRecord peek = peek(); LogRecord update = apply(peek != null ? peek : record, record); if (peek != update) { update.getSourceMethodName... | @Test(expected = NullPointerException.class) public void testFormatApplyReturnsNull() { CollectorFormatter f = new ApplyReturnsNull(); for (int i = 0; i < 10; i++) { String o = f.format(new LogRecord(Level.INFO, "")); assertNotNull(o); } }
@Test(expected = NullPointerException.class) public void testFormatNull() { Coll... |
CollectorFormatter extends Formatter { @Override public String getTail(final Handler h) { super.getTail(h); return formatRecord(h, true); } CollectorFormatter(); CollectorFormatter(String format); CollectorFormatter(String format, Formatter f,
Comparator<? super LogRecord> c); @Override String format(fina... | @Test public void testFormatNextMin() throws Exception { CollectorFormatter minF = new CollectorFormatter("{7}", (Formatter) null, (Comparator<LogRecord>) null); tickMilli(); final String min = minF.getTail((Handler) null); NumberFormat.getIntegerInstance().parse(min); tickMilli(); String next = minF.getTail((Handler) ... |
LogManagerProperties extends Properties { @Override @SuppressWarnings("CloneDoesntCallSuperClone") public synchronized Object clone() { return exportCopy(defaults); } LogManagerProperties(final Properties parent, final String prefix); @Override @SuppressWarnings("CloneDoesntCallSuperClone") synchronized Object clone();... | @Test public void testClone() throws Exception { String prefix = LogManagerPropertiesTest.class.getName(); Properties parent; LogManagerProperties mp; LogManager manager = LogManager.getLogManager(); try { String key = prefix.concat(".dummy"); parent = new Properties(); parent.put(key, "value"); read(manager, parent); ... |
DurationFilter implements Filter { @Override public String toString() { boolean idle; boolean loggable; synchronized (this) { final long millis = System.currentTimeMillis(); idle = test(0L, millis); loggable = test(records, millis); } return getClass().getName() + "{records=" + records + ", duration=" + duration + ", i... | @Test public void testDeclaredClasses() throws Exception { Class<?>[] declared = DurationFilter.class.getDeclaredClasses(); assertEquals(Arrays.toString(declared), 0, declared.length); }
@Test public void testToString() { testToString(new DurationFilter()); } |
LogManagerProperties extends Properties { static boolean isReflectionClass(String name) throws Exception { String[] names = REFLECT_NAMES; if (names == null) { REFLECT_NAMES = names = reflectionClassNames(); } for (String rf : names) { if (name.equals(rf)) { return true; } } findClass(name); return false; } LogManagerP... | @Test public void testIsReflection() throws Exception { assertTrue(LogManagerProperties.isReflectionClass(Constructor.class.getName())); assertTrue(LogManagerProperties.isReflectionClass(Method.class.getName())); } |
DurationFilter implements Filter { @Override protected DurationFilter clone() throws CloneNotSupportedException { final DurationFilter clone = (DurationFilter) super.clone(); clone.count = 0L; clone.peak = 0L; clone.start = 0L; return clone; } DurationFilter(); DurationFilter(final long records, final long duration); ... | @Test public void testClone() throws Exception { DurationFilterExt source = new DurationFilterExt(); final Filter clone = source.clone(); assertNotNull(clone); assertFalse(source == clone); assertTrue(source.equals(clone)); assertEquals(source.getClass(), clone.getClass()); LogRecord r = new LogRecord(Level.INFO, ""); ... |
DurationFilter implements Filter { @SuppressWarnings("override") public boolean isLoggable(final LogRecord record) { return accept(record.getMillis()); } DurationFilter(); DurationFilter(final long records, final long duration); @Override boolean equals(final Object obj); boolean isIdle(); @Override int hashCode(); @S... | @Test public void testPredictedOverflow() { int records = 4; int duration = 4; DurationFilter sf = new DurationFilter(records, duration); for (int i = 0; i < records; i++) { LogRecord r = new LogRecord(Level.INFO, ""); setEpochMilli(r, Long.MAX_VALUE); assertTrue(sf.isLoggable(r)); } LogRecord r = new LogRecord(Level.I... |
DurationFilter implements Filter { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } final DurationFilter other = (DurationFilter) obj; if (this.records != other.records) { return false; } if (this.duration != other.d... | @Test public void testEquals() { DurationFilter one = new DurationFilter(); DurationFilter two = new DurationFilter(); assertTrue(one.equals(one)); assertTrue(two.equals(two)); assertTrue(one.equals(two)); assertTrue(two.equals(one)); LogRecord r = new LogRecord(Level.INFO, ""); assertTrue(one.isLoggable(r)); assertTru... |
DurationFilter implements Filter { @Override public int hashCode() { int hash = 3; hash = 89 * hash + (int) (this.records ^ (this.records >>> 32)); hash = 89 * hash + (int) (this.duration ^ (this.duration >>> 32)); return hash; } DurationFilter(); DurationFilter(final long records, final long duration); @Override bool... | @Test public void testHashCode() { DurationFilter one = new DurationFilter(10, 10); DurationFilter two = new DurationFilter(10, 10); DurationFilter three = new DurationFilter(3, 3); assertTrue(one.hashCode() == two.hashCode()); assertFalse(one.hashCode() == three.hashCode()); LogRecord r = new LogRecord(Level.INFO, "")... |
LineInputStream extends FilterInputStream { @SuppressWarnings("deprecation") public String readLine() throws IOException { byte[] buf = lineBuffer; if (buf == null) buf = lineBuffer = new byte[128]; int c1; int room = buf.length; int offset = 0; while ((c1 = in.read()) != -1) { if (c1 == '\n') break; else if (c1 == '\r... | @Test public void testLines() throws IOException { for (String s : lines) { LineInputStream is = createStream(s); assertEquals("line1", is.readLine()); assertEquals("line2", is.readLine()); assertEquals("line3", is.readLine()); assertEquals(null, is.readLine()); } }
@Test public void testEmpty() throws IOException { fo... |
WriteTimeoutSocket extends Socket { @Override public String toString() { return socket.toString(); } WriteTimeoutSocket(Socket socket, int timeout); WriteTimeoutSocket(int timeout); WriteTimeoutSocket(InetAddress address, int port, int timeout); WriteTimeoutSocket(InetAddress address, int port,
InetAddress localA... | @Test public void testOverrides() throws Exception { Set<String> socketMethods = new HashSet<>(); Method[] m = java.net.Socket.class.getDeclaredMethods(); String className = java.net.Socket.class.getName() + "."; for (int i = 0; i < m.length; i++) { if (Modifier.isPublic(m[i].getModifiers()) && !Modifier.isStatic(m[i].... |
Response { public String readAtom() { return readDelimString(ATOM_CHAR_DELIM); } Response(String s); Response(String s, boolean supportsUtf8); Response(Protocol p); Response(Response r); static Response byeResponse(Exception ex); boolean supportsUtf8(); void skipSpaces(); boolean isNextNonSpace(char c); void skipTok... | @Test public void testAtom() throws Exception { for (String s : atomTests) { Response r = new Response("* " + s); assertEquals("atom", r.readAtom()); } for (String s : atomTests) { Response r = new Response("* " + s + " "); assertEquals("atom", r.readAtom()); } } |
Response { public String readAtomString() { return (String)parseString(true, true); } Response(String s); Response(String s, boolean supportsUtf8); Response(Protocol p); Response(Response r); static Response byeResponse(Exception ex); boolean supportsUtf8(); void skipSpaces(); boolean isNextNonSpace(char c); void sk... | @Test public void testAString() throws Exception { for (String s : astringTests) { Response r = new Response("* " + s); assertEquals("atom", r.readAtomString()); } for (String s : astringTests) { Response r = new Response("* " + s + " "); assertEquals("atom", r.readAtomString()); } }
@Test public void testAStringSpecia... |
Response { public String[] readAtomStringList() { return readStringList(true); } Response(String s); Response(String s, boolean supportsUtf8); Response(Protocol p); Response(Response r); static Response byeResponse(Exception ex); boolean supportsUtf8(); void skipSpaces(); boolean isNextNonSpace(char c); void skipTok... | @Test public void testAStringList() throws Exception { Response r = new Response("* " + "(A B C)"); assertArrayEquals(new String[] { "A", "B", "C" }, r.readAtomStringList()); }
@Test public void testAStringListInitialSpace() throws Exception { Response r = new Response("* " + "( A B C)"); assertArrayEquals(new String[]... |
LogManagerProperties extends Properties { static String getLocalHost(final Object s) throws Exception { try { final Method m = s.getClass().getMethod("getLocalHost"); if (!Modifier.isStatic(m.getModifiers()) && m.getReturnType() == String.class) { return (String) m.invoke(s); } else { throw new NoSuchMethodException(m.... | @Test public void testGetLocalHost() throws Exception { String host = LogManagerPropertiesTest.class.getName(); Properties p = new Properties(); p.setProperty("mail.smtp.localhost", host); Session s = Session.getInstance(p); Transport t = s.getTransport(InternetAddress.getLocalAddress(s)); try { String h = LogManagerPr... |
Response { public String[] readStringList() { return readStringList(false); } Response(String s); Response(String s, boolean supportsUtf8); Response(Protocol p); Response(Response r); static Response byeResponse(Exception ex); boolean supportsUtf8(); void skipSpaces(); boolean isNextNonSpace(char c); void skipToken(... | @Test public void testBadStringList() throws Exception { Response response = new Response( "* (\"name\", \"test\", \"version\", \"1.0\")"); String[] list = response.readStringList(); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.