List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java
private void configVDTagsComboBox(JTable table, int columnIndex) { TableColumnModel columnModel = table.getColumnModel(); TableColumn comboColumn = columnModel.getColumn(columnIndex); JComboBox<String> comboBox = new JComboBox<>(); EnumSet<VideoDataTags> allVDTags = EnumSet.allOf(VideoDataTags.class); for (VideoDataTags videoDataTag : allVDTags) { comboBox.addItem(videoDataTag.toString()); }/*from w w w.ja v a 2 s. c om*/ comboColumn.setCellEditor(new DefaultCellEditor(comboBox)); /* * allows clearing a problem when cell editor is interrupted, very deep problem. * Only shows if: (A) combobox selection is interupted, (B) dialog is * closed , and (C) Wizard is entered from the menu in this exact order */ cellEditor = comboColumn.getCellEditor(); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setToolTipText(ResourceBundleHelper.getMessageString("videoTab.tooltip")); comboColumn.setCellRenderer(renderer); }
From source file:org.apache.hadoop.tools.mapred.TestCopyMapper.java
@Test(timeout = 40000) public void testSkipCopyNoPerms() { try {/* w w w. jav a 2 s . com*/ deleteState(); createSourceData(); UserGroupInformation tmpUser = UserGroupInformation.createRemoteUser("guest"); final CopyMapper copyMapper = new CopyMapper(); final StubContext stubContext = tmpUser.doAs(new PrivilegedAction<StubContext>() { @Override public StubContext run() { try { return new StubContext(getConfiguration(), null, 0); } catch (Exception e) { LOG.error("Exception encountered ", e); throw new RuntimeException(e); } } }); final Mapper<Text, CopyListingFileStatus, Text, Text>.Context context = stubContext.getContext(); EnumSet<DistCpOptions.FileAttribute> preserveStatus = EnumSet.allOf(DistCpOptions.FileAttribute.class); preserveStatus.remove(DistCpOptions.FileAttribute.ACL); preserveStatus.remove(DistCpOptions.FileAttribute.XATTR); preserveStatus.remove(DistCpOptions.FileAttribute.TIMES); context.getConfiguration().set(DistCpConstants.CONF_LABEL_PRESERVE_STATUS, DistCpUtils.packAttributes(preserveStatus)); touchFile(SOURCE_PATH + "/src/file"); touchFile(TARGET_PATH + "/src/file"); cluster.getFileSystem().setPermission(new Path(SOURCE_PATH + "/src/file"), new FsPermission(FsAction.READ, FsAction.READ, FsAction.READ)); cluster.getFileSystem().setPermission(new Path(TARGET_PATH + "/src/file"), new FsPermission(FsAction.READ, FsAction.READ, FsAction.READ)); final FileSystem tmpFS = tmpUser.doAs(new PrivilegedAction<FileSystem>() { @Override public FileSystem run() { try { return FileSystem.get(configuration); } catch (IOException e) { LOG.error("Exception encountered ", e); Assert.fail("Test failed: " + e.getMessage()); throw new RuntimeException("Test ought to fail here"); } } }); tmpUser.doAs(new PrivilegedAction<Integer>() { @Override public Integer run() { try { copyMapper.setup(context); copyMapper.map(new Text("/src/file"), new CopyListingFileStatus(tmpFS.getFileStatus(new Path(SOURCE_PATH + "/src/file"))), context); Assert.assertEquals(stubContext.getWriter().values().size(), 1); Assert.assertTrue(stubContext.getWriter().values().get(0).toString().startsWith("SKIP")); Assert.assertTrue(stubContext.getWriter().values().get(0).toString() .contains(SOURCE_PATH + "/src/file")); } catch (Exception e) { throw new RuntimeException(e); } return null; } }); } catch (Exception e) { LOG.error("Exception encountered ", e); Assert.fail("Test failed: " + e.getMessage()); } }
From source file:org.apache.accumulo.proxy.SimpleTest.java
@Test(timeout = 10000) public void tableNotFound() throws Exception { final String doesNotExist = "doesNotExists"; try {// ww w . j a v a2 s .c o m client.addConstraint(creds, doesNotExist, NumericValueConstraint.class.getName()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.addSplits(creds, doesNotExist, Collections.<ByteBuffer>emptySet()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200")); try { client.attachIterator(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.cancelCompaction(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.checkIteratorConflicts(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.clearLocatorCache(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { final String TABLE_TEST = makeTableName(); client.cloneTable(creds, doesNotExist, TABLE_TEST, false, null, null); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.compactTable(creds, doesNotExist, null, null, null, true, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createBatchScanner(creds, doesNotExist, new BatchScanOptions()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createScanner(creds, doesNotExist, new ScanOptions()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createWriter(creds, doesNotExist, new WriterOptions()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.deleteRows(creds, doesNotExist, null, null); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.deleteTable(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.exportTable(creds, doesNotExist, "/tmp"); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.flushTable(creds, doesNotExist, null, null, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getIteratorSetting(creds, doesNotExist, "foo", IteratorScope.SCAN); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getLocalityGroups(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getMaxRow(creds, doesNotExist, Collections.<ByteBuffer>emptySet(), null, false, null, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getTableProperties(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.grantTablePermission(creds, "root", doesNotExist, TablePermission.WRITE); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.hasTablePermission(creds, "root", doesNotExist, TablePermission.WRITE); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { File newFolder = folder.newFolder(); client.importDirectory(creds, doesNotExist, "/tmp", newFolder.getAbsolutePath(), true); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.listConstraints(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.listSplits(creds, doesNotExist, 10000); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.mergeTablets(creds, doesNotExist, null, null); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.offlineTable(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.onlineTable(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.removeConstraint(creds, doesNotExist, 0); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.removeIterator(creds, doesNotExist, "name", EnumSet.allOf(IteratorScope.class)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.removeTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.renameTable(creds, doesNotExist, "someTableName"); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.revokeTablePermission(creds, "root", doesNotExist, TablePermission.ALTER_TABLE); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.setTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey(), "0"); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.splitRangeByTablets(creds, doesNotExist, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.updateAndFlush(creds, doesNotExist, new HashMap<ByteBuffer, List<ColumnUpdate>>()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getDiskUsage(creds, Collections.singleton(doesNotExist)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.testTableClassLoad(creds, doesNotExist, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createConditionalWriter(creds, doesNotExist, new ConditionalWriterOptions()); } catch (TableNotFoundException ex) { } }
From source file:nl.strohalm.cyclos.controls.customization.fields.EditCustomFieldAction.java
@Override protected void prepareForm(final ActionContext context) throws Exception { final HttpServletRequest request = context.getRequest(); final EditCustomFieldForm form = context.getForm(); final long id = form.getFieldId(); final CustomField.Nature nature = getNature(form); CustomField field;//from w w w. java2s . c o m final BaseCustomFieldService<CustomField> service = resolveService(nature); if (id <= 0L) { field = nature.getEntityType().newInstance(); switch (nature) { case OPERATOR: ((OperatorCustomField) field).setMember((Member) context.getElement()); break; case MEMBER_RECORD: final MemberRecordType memberRecordType = memberRecordTypeService .load(form.getMemberRecordTypeId()); ((MemberRecordCustomField) field).setMemberRecordType(memberRecordType); break; case PAYMENT: final TransferType transferType = transferTypeService.load(form.getTransferTypeId()); ((PaymentCustomField) field).setTransferType(transferType); break; } // Retrieve the possible parent fields final List<? extends CustomField> possibleParentFields = service.listPossibleParentFields(field); request.setAttribute("possibleParentFields", possibleParentFields); } else { field = service.load(id); // Get the possible values according to the selected parent value, if any Collection<CustomFieldPossibleValue> possibleValues; final CustomField parent = field.getParent(); if (parent == null) { // No parent - use all possibleValues = field.getPossibleValues(false); } else { final long parentValueId = form.getParentValueId(); CustomFieldPossibleValue parentValue = null; if (parentValueId > 0L) { // There's a parent value - load it parentValue = service.loadPossibleValue(parentValueId); } else { // No parent value selected - check whether the parent has at least one and select it if (parent != null && CollectionUtils.isNotEmpty(parent.getPossibleValues(false))) { parentValue = parent.getPossibleValues(false).iterator().next(); form.setParentValueId(parentValue.getId()); } } possibleValues = field.getPossibleValuesByParent(parentValue, false); } request.setAttribute("possibleValues", possibleValues); } getDataBinder(nature).writeAsString(form.getField(), field); request.setAttribute("field", field); request.setAttribute("nature", nature.name()); RequestHelper.storeEnum(request, CustomField.Control.class, "controls"); RequestHelper.storeEnum(request, CustomField.Type.class, "types"); RequestHelper.storeEnum(request, CustomField.Size.class, "sizes"); // Check the whether the field can be managed boolean canManage = false; switch (nature) { case OPERATOR: canManage = permissionService.hasPermission(MemberPermission.OPERATORS_MANAGE); break; case MEMBER_RECORD: canManage = permissionService.hasPermission(AdminSystemPermission.MEMBER_RECORD_TYPES_MANAGE); break; case PAYMENT: final PaymentCustomField paymentField = (PaymentCustomField) field; final TransferType backToTransferType = transferTypeService .load(paymentField.getTransferType().getId()); if (paymentField.getTransferType().equals(backToTransferType)) { // When should back to another TT, the form is not editable canManage = permissionService.hasPermission(AdminSystemPermission.ACCOUNTS_MANAGE); } request.setAttribute("backToTransferType", backToTransferType); break; default: canManage = permissionService.hasPermission(AdminSystemPermission.CUSTOM_FIELDS_MANAGE); break; } request.setAttribute("canManage", canManage); // Store specific nature values final GroupQuery groupQuery = new GroupQuery(); groupQuery.setStatus(Group.Status.NORMAL); switch (nature) { case MEMBER: // View may be any access level but WEB_SERVICE request.setAttribute("accessForView", EnumSet.complementOf(EnumSet.of(MemberCustomField.Access.WEB_SERVICE))); // Edit access level can be any but OTHER and WEB_SERVICE request.setAttribute("accessForEdit", EnumSet.complementOf( EnumSet.of(MemberCustomField.Access.OTHER, MemberCustomField.Access.WEB_SERVICE))); // The member search and ads search includes WEB_SERVICE request.setAttribute("memberAndAdsAccess", EnumSet.of(MemberCustomField.Access.NONE, MemberCustomField.Access.WEB_SERVICE, MemberCustomField.Access.ADMIN, MemberCustomField.Access.BROKER, MemberCustomField.Access.MEMBER)); // The others (searches, etc.) are only NONE, ADMIN, BROKER or MEMBER request.setAttribute("access", EnumSet.of(MemberCustomField.Access.NONE, MemberCustomField.Access.ADMIN, MemberCustomField.Access.BROKER, MemberCustomField.Access.MEMBER)); groupQuery.setNatures(Group.Nature.MEMBER, Group.Nature.BROKER); request.setAttribute("groups", groupService.search(groupQuery)); RequestHelper.storeEnum(request, MemberCustomField.Indexing.class, "indexings"); break; case ADMIN: groupQuery.setNatures(Group.Nature.ADMIN); request.setAttribute("groups", groupService.search(groupQuery)); break; case OPERATOR: RequestHelper.storeEnum(request, OperatorCustomField.Visibility.class, "visibilities"); break; case AD: RequestHelper.storeEnum(request, AdCustomField.Visibility.class, "visibilities"); break; case MEMBER_RECORD: final MemberRecordCustomField memberRecordCustomField = (MemberRecordCustomField) field; request.setAttribute("memberRecordType", memberRecordCustomField.getMemberRecordType()); RequestHelper.storeEnum(request, MemberRecordCustomField.Access.class, "accesses"); break; case PAYMENT: final PaymentCustomField paymentCustomField = (PaymentCustomField) field; final TransferType transferType = paymentCustomField.getTransferType(); request.setAttribute("transferType", transferType); final Set<PaymentCustomField.Access> accesses = EnumSet.allOf(PaymentCustomField.Access.class); if (paymentCustomField.getTransferType().getFixedDestinationMember() == null) { accesses.remove(PaymentCustomField.Access.DESTINATION_MEMBER); } request.setAttribute("accesses", accesses); break; } }
From source file:org.apache.accumulo.proxy.SimpleProxyIT.java
@Test(timeout = 10000) public void tableNotFound() throws Exception { final String doesNotExist = "doesNotExists"; try {//w w w . j a v a2 s . co m client.addConstraint(creds, doesNotExist, NumericValueConstraint.class.getName()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.addSplits(creds, doesNotExist, Collections.<ByteBuffer>emptySet()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } final IteratorSetting setting = new IteratorSetting(100, "slow", SlowIterator.class.getName(), Collections.singletonMap("sleepTime", "200")); try { client.attachIterator(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.cancelCompaction(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.checkIteratorConflicts(creds, doesNotExist, setting, EnumSet.allOf(IteratorScope.class)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.clearLocatorCache(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { final String TABLE_TEST = makeTableName(); client.cloneTable(creds, doesNotExist, TABLE_TEST, false, null, null); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.compactTable(creds, doesNotExist, null, null, null, true, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createBatchScanner(creds, doesNotExist, new BatchScanOptions()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createScanner(creds, doesNotExist, new ScanOptions()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createWriter(creds, doesNotExist, new WriterOptions()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.deleteRows(creds, doesNotExist, null, null); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.deleteTable(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.exportTable(creds, doesNotExist, "/tmp"); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.flushTable(creds, doesNotExist, null, null, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getIteratorSetting(creds, doesNotExist, "foo", IteratorScope.SCAN); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getLocalityGroups(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getMaxRow(creds, doesNotExist, Collections.<ByteBuffer>emptySet(), null, false, null, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getTableProperties(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.grantTablePermission(creds, "root", doesNotExist, TablePermission.WRITE); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.hasTablePermission(creds, "root", doesNotExist, TablePermission.WRITE); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { File importDir = tempFolder.newFolder("importDir"); File failuresDir = tempFolder.newFolder("failuresDir"); client.importDirectory(creds, doesNotExist, importDir.getAbsolutePath(), failuresDir.getAbsolutePath(), true); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.listConstraints(creds, doesNotExist); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.listSplits(creds, doesNotExist, 10000); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.mergeTablets(creds, doesNotExist, null, null); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.offlineTable(creds, doesNotExist, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.onlineTable(creds, doesNotExist, false); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.removeConstraint(creds, doesNotExist, 0); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.removeIterator(creds, doesNotExist, "name", EnumSet.allOf(IteratorScope.class)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.removeTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.renameTable(creds, doesNotExist, "someTableName"); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.revokeTablePermission(creds, "root", doesNotExist, TablePermission.ALTER_TABLE); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.setTableProperty(creds, doesNotExist, Property.TABLE_FILE_MAX.getKey(), "0"); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.splitRangeByTablets(creds, doesNotExist, client.getRowRange(ByteBuffer.wrap("row".getBytes())), 10); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.updateAndFlush(creds, doesNotExist, new HashMap<ByteBuffer, List<ColumnUpdate>>()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.getDiskUsage(creds, Collections.singleton(doesNotExist)); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.testTableClassLoad(creds, doesNotExist, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName()); fail("exception not thrown"); } catch (TableNotFoundException ex) { } try { client.createConditionalWriter(creds, doesNotExist, new ConditionalWriterOptions()); } catch (TableNotFoundException ex) { } }
From source file:com.moviejukebox.scanner.artwork.ArtworkScanner.java
/** * Return a list of the required artwork types * * @return//from w w w . ja va 2s . com */ public static Set<ArtworkType> getRequiredArtworkTypes() { Set<ArtworkType> artworkTypeRequired = EnumSet.noneOf(ArtworkType.class); for (ArtworkType artworkType : EnumSet.allOf(ArtworkType.class)) { if (isRequired(artworkType)) { artworkTypeRequired.add(artworkType); } } return artworkTypeRequired; }
From source file:org.apache.kylin.rest.service.JobService.java
public List<CubingJob> listJobsByRealizationName(final String realizationName, final String projectName) { return listJobsByRealizationName(realizationName, projectName, EnumSet.allOf(ExecutableState.class)); }
From source file:com.inmobi.conduit.distcp.tools.mapred.TestCopyMapper.java
@Test public void testSkipCopyNoPerms() { try {//from w w w . j av a2 s . c o m deleteState(); createSourceData(); final InMemoryWriter writer = new InMemoryWriter(); UserGroupInformation tmpUser = UserGroupInformation.createRemoteUser("guest"); final CopyMapper copyMapper = new CopyMapper(); final Mapper<Text, FileStatus, NullWritable, Text>.Context context = tmpUser .doAs(new PrivilegedAction<Mapper<Text, FileStatus, NullWritable, Text>.Context>() { @Override public Mapper<Text, FileStatus, NullWritable, Text>.Context run() { try { StatusReporter reporter = new StubStatusReporter(); return getMapperContext(copyMapper, reporter, writer); } catch (Exception e) { LOG.error("Exception encountered ", e); throw new RuntimeException(e); } } }); EnumSet<DistCpOptions.FileAttribute> preserveStatus = EnumSet.allOf(DistCpOptions.FileAttribute.class); context.getConfiguration().set(DistCpConstants.CONF_LABEL_PRESERVE_STATUS, DistCpUtils.packAttributes(preserveStatus)); touchFile(SOURCE_PATH + "/src/file.gz"); touchFile(TARGET_PATH + "/src/file.gz"); cluster.getFileSystem().setPermission(new Path(SOURCE_PATH + "/src/file.gz"), new FsPermission(FsAction.READ, FsAction.READ, FsAction.READ)); cluster.getFileSystem().setPermission(new Path(TARGET_PATH + "/src/file.gz"), new FsPermission(FsAction.READ, FsAction.READ, FsAction.READ)); final FileSystem tmpFS = tmpUser.doAs(new PrivilegedAction<FileSystem>() { @Override public FileSystem run() { try { return FileSystem.get(configuration); } catch (IOException e) { LOG.error("Exception encountered ", e); Assert.fail("Test failed: " + e.getMessage()); throw new RuntimeException("Test ought to fail here"); } } }); tmpUser.doAs(new PrivilegedAction<Integer>() { @Override public Integer run() { try { copyMapper.setup(context); copyMapper.map(new Text("/src/file.gz"), tmpFS.getFileStatus(new Path(SOURCE_PATH + "/src/file.gz")), context); } catch (Exception e) { throw new RuntimeException(e); } return null; } }); } catch (Exception e) { LOG.error("Exception encountered ", e); Assert.fail("Test failed: " + e.getMessage()); } }
From source file:gov.va.vinci.leo.ae.LeoBaseAnnotator.java
/** * Returns parameters defined in a static class named Param with static ConfigurationParameter objects. * <p/>/*from w ww . ja va2 s. c o m*/ * For Example: * <p/> * <pre> * {@code * protected String parameterName = "parameter value"; * * public static class Param { * public static ConfigurationParameter PARAMETER_NAME * = new ConfigurationParameterImpl( * "parameterName", "Description", "String", false, true, new String[] {} * ); * } * }</pre> * * @return the annotator parameters this annotator can accept. * @throws IllegalAccessException if there is an exception trying to get annotator parameters via reflection. */ protected ConfigurationParameter[] getAnnotatorParams() throws IllegalAccessException { ConfigurationParameter params[] = null; for (Class c : this.getClass().getDeclaredClasses()) { if (c.isEnum() && Arrays.asList(c.getInterfaces()).contains(ConfigurationParameter.class)) { params = new ConfigurationParameter[EnumSet.allOf(c).size()]; int counter = 0; for (Object o : EnumSet.allOf(c)) { params[counter] = ((ConfigurationParameter) o); counter++; } break; } else if (c.getCanonicalName().endsWith(".Param")) { Field[] fields = c.getFields(); List<ConfigurationParameter> paramList = new ArrayList<ConfigurationParameter>(); for (Field f : fields) { if (ConfigurationParameter.class.isAssignableFrom(f.getType())) { paramList.add((ConfigurationParameter) f.get(null)); } } params = paramList.toArray(new ConfigurationParameter[paramList.size()]); } } return params; }
From source file:com.playtech.portal.platform.service.configuration.key.ConfigurationPropKeys.java
public static ConfigurationPropKeys getByPropKey(String propKey) { if (StringUtils.isEmpty(propKey)) { return null; }//from w w w . j a va 2 s . c o m for (ConfigurationPropKeys element : EnumSet.allOf(ConfigurationPropKeys.class)) { if (propKey.equalsIgnoreCase(element.getPropKey())) { return element; } } return null; }