private static void checkRegionFile( File world, File region, RegionFile regionFile, DefaultErrorHandler results, CheckParameters params) { for (int i = 0; i < 1024; i++) { ChunkOffset offset = new ChunkOffset(i); Chunk chunk = new Chunk(world, region, offset, regionFile.getX(), regionFile.getZ()); switch (regionFile.getChunkStatus(offset)) { case NOT_PRESENT: break; case INVALID: results.corruptChunk( chunk, "Region file header had corrupt chunk offset", EnumSet.of(NONE), NONE); break; case OK: try { checkChunk(chunk, regionFile.readChunk(offset), results, params); } catch (IOException ex) { results.corruptChunk(chunk, ex.getMessage(), EnumSet.of(NONE), NONE); } break; } } }
private void doWriteAndAbort(DistributedFileSystem fs, Path path) throws IOException { fs.mkdirs(path); fs.allowSnapshot(path); DFSTestUtil.createFile(fs, new Path("/test/test1"), 100, (short) 2, 100024L); DFSTestUtil.createFile(fs, new Path("/test/test2"), 100, (short) 2, 100024L); Path file = new Path("/test/test/test2"); FSDataOutputStream out = fs.create(file); for (int i = 0; i < 2; i++) { long count = 0; while (count < 1048576) { out.writeBytes("hell"); count += 4; } } ((DFSOutputStream) out.getWrappedStream()).hsync(EnumSet.of(SyncFlag.UPDATE_LENGTH)); DFSTestUtil.abortStream((DFSOutputStream) out.getWrappedStream()); Path file2 = new Path("/test/test/test3"); FSDataOutputStream out2 = fs.create(file2); for (int i = 0; i < 2; i++) { long count = 0; while (count < 1048576) { out2.writeBytes("hell"); count += 4; } } ((DFSOutputStream) out2.getWrappedStream()).hsync(EnumSet.of(SyncFlag.UPDATE_LENGTH)); DFSTestUtil.abortStream((DFSOutputStream) out2.getWrappedStream()); fs.createSnapshot(path, "s1"); }
@Test public void getOrCreateMatchingSessionShouldReturnSameMatchingGameSessionForSecondTime() { when(mockGameFactory.create(1, 0, false, false, null, false, GameMode.WHOLE)) .thenReturn(mockGame1); when(mockGame1.getTransition()).thenReturn(Transition.Matching); List<Game> games = Lists.newArrayList(); for (int i = 0; i < 2; ++i) { Game game = gameManager.getOrCreateMatchingSession( GameMode.WHOLE, null, 0, null, EnumSet.of(ProblemGenre.Anige), EnumSet.of(ProblemType.Marubatsu), false, mockServerStatusManager, 12345678, "192.168.0.1"); games.add(game); } assertEquals(ImmutableList.of(mockGame1, mockGame1), games); }
@Test public void getNumberOfPlayersShouldReturnTotalNumberOfHumanPlayers() { when(mockGameFactory.create(1, 0, true, false, null, true, GameMode.EVENT)) .thenReturn(mockGame1); when(mockGame1.getNumberOfHumanPlayer()).thenReturn(1); when(mockGameFactory.create(2, 0, true, false, null, false, GameMode.EVENT)) .thenReturn(mockGame2); when(mockGame2.getNumberOfHumanPlayer()).thenReturn(2); gameManager.getOrCreateMatchingSession( GameMode.EVENT, "public EVENT name", 0, null, EnumSet.of(ProblemGenre.Anige), EnumSet.of(ProblemType.Marubatsu), true, mockServerStatusManager, 12345678, "192.168.0.1"); gameManager.getOrCreateMatchingSession( GameMode.EVENT, "closed EVENT name", 0, null, EnumSet.of(ProblemGenre.Anige), EnumSet.of(ProblemType.Marubatsu), false, mockServerStatusManager, 12345678, "192.168.0.1"); assertEquals(3, gameManager.getNumberOfPlayers()); }
protected Handler createAppServlet( Server server, JerseyEnvironment jersey, ObjectMapper objectMapper, Validator validator, MutableServletContextHandler handler, @Nullable Servlet jerseyContainer, MetricRegistry metricRegistry) { configureSessionsAndSecurity(handler, server); handler .addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)) .setInitParameter( AllowedMethodsFilter.ALLOWED_METHODS_PARAM, Joiner.on(',').join(allowedMethods)); handler.addFilter(ThreadNameFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); serverPush.addFilter(handler); if (jerseyContainer != null) { if (jerseyRootPath.isPresent()) { jersey.setUrlPattern(jerseyRootPath.get()); } jersey.register(new JacksonMessageBodyProvider(objectMapper)); jersey.register(new HibernateValidationFeature(validator)); if (registerDefaultExceptionMappers == null || registerDefaultExceptionMappers) { jersey.register(new LoggingExceptionMapper<Throwable>() {}); jersey.register(new JerseyViolationExceptionMapper()); jersey.register(new JsonProcessingExceptionMapper()); jersey.register(new EarlyEofExceptionMapper()); } handler.addServlet(new NonblockingServletHolder(jerseyContainer), jersey.getUrlPattern()); } final InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry); instrumented.setServer(server); instrumented.setHandler(handler); return instrumented; }
private void onCreate(ChannelHandlerContext ctx) throws IOException, URISyntaxException { writeContinueHeader(ctx); final String nnId = params.namenodeId(); final int bufferSize = params.bufferSize(); final short replication = params.replication(); final long blockSize = params.blockSize(); final FsPermission permission = params.permission(); EnumSet<CreateFlag> flags = params.overwrite() ? EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE) : EnumSet.of(CreateFlag.CREATE); final DFSClient dfsClient = newDfsClient(nnId, confForCreate); OutputStream out = dfsClient.createWrappedOutputStream( dfsClient.create( path, permission, flags, replication, blockSize, null, bufferSize, null), null); DefaultHttpResponse resp = new DefaultHttpResponse(HTTP_1_1, CREATED); final URI uri = new URI(HDFS_URI_SCHEME, nnId, path, null, null); resp.headers().set(LOCATION, uri.toString()); resp.headers().set(CONTENT_LENGTH, 0); ctx.pipeline() .replace(this, HdfsWriter.class.getSimpleName(), new HdfsWriter(dfsClient, out, resp)); }
private DeviceSupport createBTDeviceSupport(String deviceAddress) throws GBException { if (mBtAdapter != null && mBtAdapter.isEnabled()) { GBDevice gbDevice = null; DeviceSupport deviceSupport = null; try { BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(deviceAddress); if (btDevice.getName() == null || btDevice .getName() .startsWith("MI")) { // FIXME: workaround for Miband not being paired gbDevice = new GBDevice(deviceAddress, "MI", DeviceType.MIBAND); deviceSupport = new ServiceDeviceSupport( new MiBandSupport(), EnumSet.of( ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING)); } else if (btDevice.getName().indexOf("Pebble") == 0) { gbDevice = new GBDevice(deviceAddress, btDevice.getName(), DeviceType.PEBBLE); deviceSupport = new ServiceDeviceSupport( new PebbleSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING)); } if (deviceSupport != null) { deviceSupport.setContext(gbDevice, mBtAdapter, mContext); return deviceSupport; } } catch (Exception e) { throw new GBException(mContext.getString(R.string.cannot_connect_bt_address_invalid_, e)); } } return null; }
@Test(expected = XenonException.class) public void test3() throws XenonException { ImmutableArray<String> schemes = new ImmutableArray<>("SCHEME1", "SCHEME2"); ImmutableArray<String> locations = new ImmutableArray<>("L1", "L2"); ImmutableArray<XenonPropertyDescription> supportedProperties = new ImmutableArray<XenonPropertyDescription>( new XenonPropertyDescriptionImplementation( "xenon.adaptors.test.p1", Type.STRING, EnumSet.of(Component.XENON), "aap2", "test property p1"), new XenonPropertyDescriptionImplementation( "xenon.adaptors.test.p2", Type.STRING, EnumSet.of(Component.XENON), "noot2", "test property p2")); Map<String, String> p = new HashMap<>(2); p.put("xenon.adaptors.test.p3", "mies"); XenonProperties prop = new XenonProperties(supportedProperties, p); new TestAdaptor(null, "test", "DESCRIPTION", schemes, locations, supportedProperties, prop); }
public enum AreaColorPolicy { NEVER(EnumSet.noneOf(PuzzleType.class)), // STANDARD_SQUIGGLY(EnumSet.of(PuzzleType.STANDARD, PuzzleType.SQUIGGLY)), // // name does not include PERCENT but cannot be changed because it is used in existing user // preferences STANDARD_X_HYPER_SQUIGGLY( EnumSet.of( PuzzleType.STANDARD, PuzzleType.STANDARD_X, PuzzleType.STANDARD_HYPER, PuzzleType.STANDARD_PERCENT, PuzzleType.SQUIGGLY)), // // all except color sudoku ALWAYS( EnumSet.of( PuzzleType.STANDARD, PuzzleType.STANDARD_X, PuzzleType.STANDARD_HYPER, PuzzleType.STANDARD_PERCENT, PuzzleType.SQUIGGLY, PuzzleType.SQUIGGLY_X, PuzzleType.SQUIGGLY_HYPER, PuzzleType.SQUIGGLY_PERCENT)); private final EnumSet<PuzzleType> puzzleTypes; AreaColorPolicy(EnumSet<PuzzleType> puzzleTypes) { this.puzzleTypes = puzzleTypes; } public boolean matches(PuzzleType puzzleType) { return puzzleTypes.contains(puzzleType); } }
private void emitURIs() throws IOException { writer.emitEmptyLine(); for (Table table : mModel.getTables()) { writer.emitField( "Uri", SqlUtil.URI(table), EnumSet.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), "Uri.parse(\"content://" + mModel.getContentAuthority() + "/" + table.name.toLowerCase() + "\")"); } for (View view : mModel.getViews()) { writer.emitField( "Uri", SqlUtil.URI(view), EnumSet.of(Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL), "Uri.parse(\"content://" + mModel.getContentAuthority() + "/" + view.name.toLowerCase() + "\")"); } writer.emitEmptyLine(); }
private void init() { this.transform_ = this.createJSTransform(); this.mouseWentDown() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDown(o, e);}}"); this.mouseWentUp() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseUp(o, e);}}"); this.mouseDragged() .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDrag(o, e);}}"); this.mouseMoved() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseMoved(o, e);}}"); this.touchStarted() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchStarted(o, e);}}"); this.touchEnded() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchEnded(o, e);}}"); this.touchMoved() .addListener( "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchMoved(o, e);}}"); this.setSelectionAreaPadding(0, EnumSet.of(Side.Top)); this.setSelectionAreaPadding(20, EnumSet.of(Side.Left, Side.Right)); this.setSelectionAreaPadding(30, EnumSet.of(Side.Bottom)); if (this.chart_ != null) { this.chart_.addAxisSliderWidget(this); } }
public DecodeThread(ZXingCaptureActivity activity, int decodeMode) { this.activity = activity; handlerInitLatch = new CountDownLatch(1); hints = new EnumMap<DecodeHintType, Object>(DecodeHintType.class); Collection<BarcodeFormat> decodeFormats = new ArrayList<BarcodeFormat>(); decodeFormats.addAll(EnumSet.of(BarcodeFormat.AZTEC)); decodeFormats.addAll(EnumSet.of(BarcodeFormat.PDF_417)); switch (decodeMode) { case BARCODE_MODE: decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats()); break; case QRCODE_MODE: decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats()); break; case ALL_MODE: decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats()); decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats()); break; default: break; } hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); }
@Test public void testCoinbaseHeightTestnet() throws Exception { // Testnet block 21066 (hash 0000000004053156021d8e42459d284220a7f6e087bf78f30179c3703ca4eefa) // contains a coinbase transaction whose height is two bytes, which is // shorter than we see in most other cases. Block block = TestNet3Params.get() .getDefaultSerializer() .makeBlock( ByteStreams.toByteArray(getClass().getResourceAsStream("block_testnet21066.dat"))); // Check block. assertEquals( "0000000004053156021d8e42459d284220a7f6e087bf78f30179c3703ca4eefa", block.getHashAsString()); block.verify(21066, EnumSet.of(Block.VerifyFlag.HEIGHT_IN_COINBASE)); // Testnet block 32768 (hash 000000007590ba495b58338a5806c2b6f10af921a70dbd814e0da3c6957c0c03) // contains a coinbase transaction whose height is three bytes, but could // fit in two bytes. This test primarily ensures script encoding checks // are applied correctly. block = TestNet3Params.get() .getDefaultSerializer() .makeBlock( ByteStreams.toByteArray(getClass().getResourceAsStream("block_testnet32768.dat"))); // Check block. assertEquals( "000000007590ba495b58338a5806c2b6f10af921a70dbd814e0da3c6957c0c03", block.getHashAsString()); block.verify(32768, EnumSet.of(Block.VerifyFlag.HEIGHT_IN_COINBASE)); }
private Operator intersectXYintersectZ( int x, int y, IntersectOption xyOutput, int z, IntersectOption xyzOutput, boolean skip) { Ordering xOrdering = new Ordering(); xOrdering.append(field(tXIndexRowType, 1), true); Ordering yOrdering = new Ordering(); yOrdering.append(field(tYIndexRowType, 1), true); Ordering zOrdering = new Ordering(); zOrdering.append(field(tZIndexRowType, 1), true); IntersectOption scanType = skip ? IntersectOption.SKIP_SCAN : IntersectOption.SEQUENTIAL_SCAN; return intersect_Ordered( intersect_Ordered( indexScan_Default(tXIndexRowType, xEq(x), xOrdering), indexScan_Default(tYIndexRowType, yEq(y), yOrdering), tXIndexRowType, tYIndexRowType, 1, 1, ascending(true), JoinType.INNER_JOIN, EnumSet.of(scanType, xyOutput), null, true), indexScan_Default(tZIndexRowType, zEq(z), zOrdering), xyOutput == LEFT ? tXIndexRowType : tYIndexRowType, tZIndexRowType, 1, 1, ascending(true), JoinType.INNER_JOIN, EnumSet.of(scanType, xyzOutput), null, true); }
// package default public ProcessCleanupConfImpl(TDeployment.Process pinfo) { for (TCleanup cleanup : pinfo.getCleanupList()) { if (cleanup.getOn() == TCleanup.On.SUCCESS || cleanup.getOn() == TCleanup.On.ALWAYS) { processACleanup(successCategories, cleanup.getCategoryList()); } if (cleanup.getOn() == TCleanup.On.FAILURE || cleanup.getOn() == TCleanup.On.ALWAYS) { processACleanup(failureCategories, cleanup.getCategoryList()); } } // validate configurations Set<CLEANUP_CATEGORY> categories = getCleanupCategories(true); if (categories.contains(CLEANUP_CATEGORY.INSTANCE) && !categories.containsAll( EnumSet.of(CLEANUP_CATEGORY.CORRELATIONS, CLEANUP_CATEGORY.VARIABLES))) { throw new ContextException( "Cleanup configuration error: the instance category requires both the correlations and variables categories specified together!!!"); } categories = getCleanupCategories(false); if (categories.contains(CLEANUP_CATEGORY.INSTANCE) && !categories.containsAll( EnumSet.of(CLEANUP_CATEGORY.CORRELATIONS, CLEANUP_CATEGORY.VARIABLES))) { throw new ContextException( "Cleanup configuration error: the instance category requires both the correlations and variables categories specified together!!!"); } }
public void testEnhanceDefer() throws IOException { NetcdfDataset ncd = NetcdfDataset.openDataset( filename, EnumSet.of(NetcdfDataset.Enhance.ScaleMissing), -1, null, null); VariableDS enhancedVar = (VariableDS) ncd.findVariable("t1"); NetcdfDataset ncdefer = NetcdfDataset.openDataset( filename, EnumSet.of(NetcdfDataset.Enhance.ScaleMissingDefer), -1, null, null); VariableDS deferVar = (VariableDS) ncdefer.findVariable("t1"); Array data = enhancedVar.read(); Array dataDefer = deferVar.read(); System.out.printf("Enhanced="); NCdumpW.printArray(data); System.out.printf("%nDeferred="); NCdumpW.printArray(dataDefer); System.out.printf("%nProcessed="); CompareNetcdf2 nc = new CompareNetcdf2(new Formatter(System.out), false, false, true); assert !nc.compareData(enhancedVar.getShortName(), data, dataDefer, false); IndexIterator ii = dataDefer.getIndexIterator(); while (ii.hasNext()) { double val = deferVar.convertScaleOffsetMissing(ii.getDoubleNext()); ii.setDoubleCurrent(val); } NCdumpW.printArray(dataDefer); assert nc.compareData(enhancedVar.getShortName(), data, dataDefer, false); ncd.close(); ncdefer.close(); }
protected JMenuBar createMenuBar() { JMenuBar bar = new JMenuBar(); JMenu homeMenu = new JMenu("Homing"); bar.add(homeMenu); // adding the appropriate homing options for your endstop configuration for (AxisId axis : AxisId.values()) { Endstops endstops = machine.getDriver().getMachine().getEndstops(axis); if (endstops != null) { if (endstops.hasMin == true) homeMenu.add( makeHomeItem("Home " + axis.name() + " to minimum", EnumSet.of(axis), false)); if (endstops.hasMax == true) homeMenu.add(makeHomeItem("Home " + axis.name() + " to maximum", EnumSet.of(axis), true)); } } /* homeMenu.add(new JSeparator()); homeMenu.add(makeHomeItem("Home XY+",EnumSet.of(Axis.X,Axis.Y),true)); homeMenu.add(makeHomeItem("Home XY-",EnumSet.of(Axis.X,Axis.Y),false)); homeMenu.add(makeHomeItem("Home all+",EnumSet.allOf(Axis.class),true)); homeMenu.add(makeHomeItem("Home all-",EnumSet.allOf(Axis.class),false)); */ return bar; }
/** * Handle rockets. * * @param world the world object * @param p the player * @param esl all enemy vessels */ static void handleRockets(SpacewarWorld world, Player p, List<SpacewarStructure> esl) { List<SpacewarStructure> rocketTargets = world.enemiesOf(p); Collections.shuffle(rocketTargets); for (SpacewarStructure s : rocketTargets) { if (world.isFleeing(s)) { continue; } // do not fire rocket at tagged objects unless it is the last enemy if (esl.size() == 1 || (s.item == null || s.item.tag == null)) { int found = 0; if (s.type == StructureType.SHIP || s.type == StructureType.STATION) { Pair<SpacewarStructure, SpacewarWeaponPort> w = findReadyPort(world.structures(p), EnumSet.of(Mode.ROCKET, Mode.MULTI_ROCKET)); if (w != null) { world.attack(w.first, s, w.second.projectile.mode); found++; } } if (s.type == StructureType.SHIELD || s.type == StructureType.PROJECTOR) { Pair<SpacewarStructure, SpacewarWeaponPort> w = findReadyPort(world.structures(p), EnumSet.of(Mode.BOMB, Mode.VIRUS)); if (w != null) { world.attack(w.first, s, w.second.projectile.mode); found++; } } if (found == 0) { // don't bother with other targets, out of ammo break; } } } }
public enum EVENT_HANDLER_TYPE { SUBMIT_FORM_EVENT_HANDLER( "SubmitFormEventHandler", EnumSet.of( ACTION_SCRIPT_IMPORT.SUBMIT_FORM_EVENT_HANDLER_AS, ACTION_SCRIPT_IMPORT.ABSTRACT_EVENT_HANDLER_AS), EnumSet.of(JAVA_SCRIPT_IMPORT.JSF_FLEX_COMMUNICATOR_EVENT_JS)), DATA_UPDATE_EVENT_HANDLER( "DataUpdateEventHandler", EnumSet.of( ACTION_SCRIPT_IMPORT.DATA_UPDATE_EVENT_HANDLER_AS, ACTION_SCRIPT_IMPORT.ABSTRACT_EVENT_HANDLER_AS), EnumSet.noneOf(JAVA_SCRIPT_IMPORT.class)), PROPERTY_UPDATE_EVENT_HANDER( "PropertyUpdateEventHandler", EnumSet.of( ACTION_SCRIPT_IMPORT.PROPERTY_UPDATE_EVENT_HANDLER_AS, ACTION_SCRIPT_IMPORT.ABSTRACT_EVENT_HANDLER_AS), EnumSet.noneOf(JAVA_SCRIPT_IMPORT.class)); private final String _actionScriptConstructor; private final EnumSet<ACTION_SCRIPT_IMPORT> _actionScriptImports; private final EnumSet<JAVA_SCRIPT_IMPORT> _javaScriptImports; EVENT_HANDLER_TYPE( String actionScriptConstructor, EnumSet<ACTION_SCRIPT_IMPORT> actionScriptImports, EnumSet<JAVA_SCRIPT_IMPORT> javaScriptImports) { _actionScriptConstructor = actionScriptConstructor; _actionScriptImports = actionScriptImports; _javaScriptImports = javaScriptImports; } public String getActionScriptConstructor() { return _actionScriptConstructor; } public EnumSet<ACTION_SCRIPT_IMPORT> getActionScriptImports() { return _actionScriptImports; } public EnumSet<JAVA_SCRIPT_IMPORT> getJavaScriptImports() { return _javaScriptImports; } public enum JAVA_SCRIPT_IMPORT { JSF_FLEX_COMMUNICATOR_EVENT_JS("jsfFlexCommunicatorEvent.js"); private final String _javaScriptImport; JAVA_SCRIPT_IMPORT(String javaScriptImport) { _javaScriptImport = javaScriptImport; } public String getJavaScriptImport() { return _javaScriptImport; } } }
public static void registerItems() { GameRegistry.registerItem(itemGem, "gemItem"); // GameRegistry.registerItem(itemTestingStaff, itemTestingStaff.getUnlocalizedName()); GameRegistry.registerItem( itemTestingGreatStaffWooden, itemTestingGreatStaffWooden.getUnlocalizedName()); GameRegistry.registerItem(itemLongBowWooden, itemLongBowWooden.getUnlocalizedName()); GameRegistry.registerItem(itemLongBowComposite, itemLongBowComposite.getUnlocalizedName()); GameRegistry.registerItem(itemLongBowMechanic, itemLongBowMechanic.getUnlocalizedName()); GameRegistry.registerItem(itemLongBowBirch, itemLongBowBirch.getUnlocalizedName()); GameRegistry.registerItem(itemBroadSword, itemBroadSword.getUnlocalizedName()); testingStaff = ItemFactory.createWeapon( EnumSet.of(EnumBattleClassesPlayerClass.MAGE), EnumBattleClassesHandHeldType.ONE_HANDED, BattleClassesMod.MODID, "WoodenStaff", 1, EnumSet.of( EnumBattleClassesAttributeType.SPELLPOWER_FIRE, EnumBattleClassesAttributeType.CRITICAL_RATING), 2F, WeaponDamageCreationMode.REAL); ItemFactory.registerItem(testingStaff); testingSet = ItemFactory.createArmorSet( EnumSet.of(EnumBattleClassesPlayerClass.MAGE), ItemFactory.ARMOR_MATERIAL_CLOTH, BattleClassesMod.MODID, "testing", 1, EnumSet.of( EnumBattleClassesAttributeType.HEALTH, EnumBattleClassesAttributeType.SPELLPOWER_FIRE, EnumBattleClassesAttributeType.CRITICAL_RATING)); ItemFactory.registerItems(testingSet); LanguageRegistry.addName(new ItemStack(itemBroadSword), "Broadsword of testing and debugging"); // LanguageRegistry.addName(new ItemStack(itemTestingStaff), "Staff of testing and debugging"); LanguageRegistry.addName( new ItemStack(itemTestingGreatStaffWooden), "Staff of testing and debugging"); LanguageRegistry.addName(new ItemStack(itemLongBowWooden), "Longbow"); LanguageRegistry.addName(new ItemStack(itemLongBowWooden), "Longbow"); LanguageRegistry.addName(new ItemStack(itemLongBowWooden), "Longbow"); LanguageRegistry.addName(new ItemStack(itemLongBowWooden), "Longbow"); LanguageRegistry.addName(new ItemStack(itemGem, 1, 0), "True Diamond"); LanguageRegistry.addName(new ItemStack(itemGem, 1, 1), "Ruby"); LanguageRegistry.addName(new ItemStack(itemGem, 1, 2), "Shappire"); LanguageRegistry.addName(new ItemStack(itemGem, 1, 3), "Lion's eye"); LanguageRegistry.addName(new ItemStack(itemGem, 1, 4), "Amethyst"); LanguageRegistry.addName(new ItemStack(itemGem, 1, 5), "Topaz"); LanguageRegistry.addName(new ItemStack(itemGem, 1, 6), "Talasite"); TabWeapons.tabIconItem = testingStaff; TabArmors.tabIconItem = testingSet[0]; }
public class AttributeParser extends Parser { public static final EnumSet<TokenType> ATTR = EnumSet.of(TokenType.DOT, TokenType.LEFT_PAREN); public static final EnumSet<TokenType> FOLL = EnumSet.of(TokenType.COLON_EQUAL, TokenType.COMMA); public AttributeParser(Parser parent) { super(parent); } @Override public Node parse(Token token) throws IOException { AttrNode node = null; if (ExpressionParser.START.contains(token.type())) { node = new AttrNode(startLine()); token = tokenizer().peek(); Token var = tokenizer().current(); if (ATTR.contains(token.type())) { boolean first = true; while (ATTR.contains(token.type())) { Node n = null; if (tokenizer().peek().type() == TokenType.LEFT_PAREN) { CallParser call = new CallParser(this); n = call.parse(var); } else if (ExpressionParser.START.contains(var.type())) { if (first) { n = ParseUtil.value(var); first = false; } else { n = ParseUtil.var(var); } } else { error(ErrorCode.INVALID_EXPR); } if (n != null) { node.add(n); token = tokenizer().next(); if (ATTR.contains(token.type())) { var = tokenizer().next(); } } } } else if (tokenizer().current().type() == TokenType.LEFT_BRACKET) { ArrayParser arrp = new ArrayParser(this); Node n = arrp.parse(tokenizer().current()); node.add(n); } else { node.add(ParseUtil.value(tokenizer().current())); tokenizer().next(); } } else { error(ErrorCode.INVALID_EXPR); } return node; } }
@Override protected Set<ServerStatus.Capability> capabilities() { if (configuration.isMaster()) { return EnumSet.of(ServerStatus.Capability.SERVER, ServerStatus.Capability.MASTER); } else { return EnumSet.of(ServerStatus.Capability.SERVER); } }
private static Pin createDigitalInputPin(int address, String name) { return new PinImpl( PiFaceGpioProvider.NAME, address, name, EnumSet.of(PinMode.DIGITAL_INPUT), EnumSet.of(PinPullResistance.PULL_UP)); }
@Override public EnumSet<PseudoResearchTypes> getPseudoParentTypes() { if (Config.wardedStone) { return EnumSet.of(PseudoResearchTypes.WARDED, PseudoResearchTypes.DISTILESSENTIA); } return EnumSet.of(PseudoResearchTypes.DISTILESSENTIA); }
/** Test regular operation, including command line parameter parsing. */ @Test(timeout = 60000) // timeout after a minute. public void testDetachedMode() { LOG.info("Starting testDetachedMode()"); addTestAppender(FlinkYarnSessionCli.class, Level.INFO); Runner runner = startWithArgs( new String[] { "-j", flinkUberjar.getAbsolutePath(), "-t", flinkLibFolder.getAbsolutePath(), "-n", "1", "-jm", "768", "-tm", "1024", "--name", "MyCustomName", // test setting a custom name "--detached" }, "Flink JobManager is now running on", RunTypes.YARN_SESSION); checkForLogString("The Flink YARN client has been started in detached mode"); Assert.assertFalse("The runner should detach.", runner.isAlive()); LOG.info("Waiting until two containers are running"); // wait until two containers are running while (getRunningContainers() < 2) { sleep(500); } LOG.info("Two containers are running. Killing the application"); // kill application "externally". try { YarnClient yc = YarnClient.createYarnClient(); yc.init(yarnConfiguration); yc.start(); List<ApplicationReport> apps = yc.getApplications(EnumSet.of(YarnApplicationState.RUNNING)); Assert.assertEquals(1, apps.size()); // Only one running ApplicationReport app = apps.get(0); Assert.assertEquals("MyCustomName", app.getName()); ApplicationId id = app.getApplicationId(); yc.killApplication(id); while (yc.getApplications(EnumSet.of(YarnApplicationState.KILLED)).size() == 0) { sleep(500); } } catch (Throwable t) { LOG.warn("Killing failed", t); Assert.fail(); } LOG.info("Finished testDetachedMode()"); }
/** * Defines a generic graphics shape with fill and stroke attributes. * * @author ferhat */ public abstract class Shape extends UIElement { /** Fill property definition */ public static PropertyDefinition fillPropDef = PropertySystem.register( "Fill", Brush.class, Shape.class, new PropertyData(null, null, EnumSet.of(PropertyFlags.Redraw))); /** Stroke property definition */ public static PropertyDefinition strokePropDef = PropertySystem.register( "Stroke", Pen.class, Shape.class, new PropertyData(null, null, EnumSet.of(PropertyFlags.Redraw))); /** ScaleMode property definition */ public static PropertyDefinition scaleModePropDef = PropertySystem.register( "ScaleMode", ScaleMode.class, Shape.class, new PropertyData(ScaleMode.None, null, EnumSet.of(PropertyFlags.Redraw))); /** Constructor. */ public Shape() { super(); } /** Gets or sets fill brush */ public Brush getFill() { return (Brush) getProperty(fillPropDef); } public void setFill(Brush value) { setProperty(fillPropDef, value); } /** Gets or sets stroke pen */ public Pen getStroke() { return (Pen) getProperty(strokePropDef); } public void setStroke(Pen value) { setProperty(strokePropDef, value); } /** Gets or sets scale mode */ public ScaleMode getScaleMode() { return (ScaleMode) getProperty(scaleModePropDef); } public void setScaleMode(ScaleMode scaleMode) { setProperty(scaleModePropDef, scaleMode); } }
@Test public void testKeysPressed3() throws Exception { ks1 = new KeyboardState(EnumSet.of(Key.A, Key.C, Key.D), KeyEvent.NOTHING); ks2 = new KeyboardState(EnumSet.of(Key.A), KeyEvent.NOTHING); final EnumSet<Key> pressed = ks2.getKeysPressedSince(ks1); assertEquals("0 key", 0, pressed.size()); }
@Test public void testWizardComparatorSinglePositionNullValue() { Player p1 = beanFactory.createPlayer().as(); p1.setWizard2B("2"); Player p2 = beanFactory.createPlayer().as(); p2.setWizard1B("1"); Comparator<Player> desc = PlayerColumn.getWizardComparator(false, EnumSet.of(FB)); Comparator<Player> asc = PlayerColumn.getWizardComparator(true, EnumSet.of(FB)); assertComparators(p1, p2, desc, asc); }
@Test public void testKeysReleased1() throws Exception { ks1 = new KeyboardState(EnumSet.of(Key.A, Key.B), KeyEvent.NOTHING); ks2 = new KeyboardState(EnumSet.of(Key.A, Key.E), KeyEvent.NOTHING); final EnumSet<Key> released = ks2.getKeysReleasedSince(ks1); assertEquals("1 key", 1, released.size()); assertTrue("b released", released.contains(Key.B)); }
private void drawInternalString(String s, float x, float y) { if (s == lastStringMeasured) { EnumSet<AlignmentFlag> flags = EnumSet.of(AlignmentFlag.AlignRight, AlignmentFlag.AlignTop); painter.drawText( x + lastStringWidth - 1000, y - getFontMetrics().getAscent(), 1000, 1000, flags, s); } else { EnumSet<AlignmentFlag> flags = EnumSet.of(AlignmentFlag.AlignLeft, AlignmentFlag.AlignTop); painter.drawText(x, y - getFontMetrics().getAscent(), 1000, 1000, flags, s); } }