org.apache.commons.lang3.reflect.FieldUtils Java Examples

The following examples show how to use org.apache.commons.lang3.reflect.FieldUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LdapObjectMapper.java    From library with Apache License 2.0 6 votes vote down vote up
/**
 * Method used to extract the values from a given attribute and put it into the domain model object
 *
 * @param clazz to instantiate the domain object
 * @param attributes to extract the values
 * @return an {@link Optional} of the domain object
 */
private Optional<T> extractValue(Class<T> clazz, Attributes attributes) {

    try {
        final T instance = clazz.getDeclaredConstructor().newInstance();

        final List<Field> fields = FieldUtils.getFieldsListWithAnnotation(instance.getClass(), LdapAttribute.class);

        for (Field field : fields) {
            final LdapAttribute annotation = field.getAnnotation(LdapAttribute.class);

            final Attribute attribute = attributes.get(annotation.value());

            if (attribute != null) {
                FieldUtils.writeField(field, instance, attribute.get(), true);
            }
        }
        return Optional.of(instance);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return Optional.empty();
}
 
Example #2
Source File: AeroRemoteApiController.java    From webanno with Apache License 2.0 6 votes vote down vote up
private static void forceOverwriteSofa(CAS aCas, String aValue)
{
    try {
        Sofa sofa = (Sofa) aCas.getSofa();
        MethodHandle _FH_sofaString = (MethodHandle) FieldUtils.readField(sofa,
                "_FH_sofaString", true);
        Method method = MethodUtils.getMatchingMethod(Sofa.class, "wrapGetIntCatchException",
                MethodHandle.class);
        int adjOffset;
        try {
            method.setAccessible(true);
            adjOffset = (int) method.invoke(null, _FH_sofaString);
        }
        finally {
            method.setAccessible(false);
        }
        sofa._setStringValueNcWj(adjOffset, aValue);
    }
    catch (Exception e) {
        throw new IllegalStateException("Cannot force-update SofA string", e);
    }
}
 
Example #3
Source File: ResultCodeTest.java    From prebid-mobile-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccessForMoPub() throws Exception {

    HttpUrl httpUrl = server.url("/");
    Host.CUSTOM.setHostUrl(httpUrl.toString());
    PrebidMobile.setPrebidServerHost(Host.CUSTOM);
    PrebidMobile.setApplicationContext(activity.getApplicationContext());
    PrebidMobile.setPrebidServerAccountId("123456");
    server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.oneBidFromAppNexus()));
    BannerAdUnit adUnit = new BannerAdUnit("123456", 300, 250);
    MoPubView testView = new MoPubView(activity);
    OnCompleteListener mockListener = mock(OnCompleteListener.class);
    adUnit.fetchDemand(testView, mockListener);
    DemandFetcher fetcher = (DemandFetcher) FieldUtils.readField(adUnit, "fetcher", true);
    PrebidMobile.setTimeoutMillis(Integer.MAX_VALUE);
    ShadowLooper fetcherLooper = shadowOf(fetcher.getHandler().getLooper());
    fetcherLooper.runOneTask();
    ShadowLooper demandLooper = shadowOf(fetcher.getDemandHandler().getLooper());
    demandLooper.runOneTask();
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    verify(mockListener).onComplete(ResultCode.SUCCESS);
    assertEquals("hb_pb:0.50,hb_env:mobile-app,hb_pb_appnexus:0.50,hb_size:300x250,hb_bidder_appnexus:appnexus,hb_bidder:appnexus,hb_cache_id:df4aba04-5e69-44b8-8608-058ab21600b8,hb_env_appnexus:mobile-app,hb_size_appnexus:300x250,hb_cache_id_appnexus:df4aba04-5e69-44b8-8608-058ab21600b8,", testView.getKeywords());

}
 
Example #4
Source File: ConnectionConf.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Clears all fields that match a particular predicate. For all primitive types, the value is set
 * to zero. For object types, the value is set to null.
 *
 * @param predicate
 */
private void clear(Predicate<Field> predicate, boolean isSecret) {
  try {
    for(Field field : FieldUtils.getAllFields(getClass())) {
      if(predicate.apply(field)) {
        if (isSecret && field.getType().equals(String.class)) {
          final String value = (String) field.get(this);

          if (Strings.isNullOrEmpty(value)) {
            field.set(this, null);
          } else {
            field.set(this, USE_EXISTING_SECRET_VALUE);
          }
        } else {
          Object defaultValue = Defaults.defaultValue(field.getType());
          field.set(this, defaultValue);
        }
      }
    }
  } catch (IllegalAccessException e) {
    throw Throwables.propagate(e);
  }
}
 
Example #5
Source File: ListTools.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T, W> List<T> extractField(List<W> list, String name, Class<T> clz, Boolean ignoreNull,
		Boolean unique) throws Exception {
	List<T> values = new ArrayList<>();
	if (isEmpty(list)) {
		return values;
	}
	for (W w : list) {
		Object o = FieldUtils.readField(w, name, true);
		if (null == o && ignoreNull) {
			continue;
		}
		if (unique && values.contains(o)) {
			continue;
		}
		if (null == o) {
			values.add(null);
		} else {
			values.add((T) o);
		}
	}
	return values;
}
 
Example #6
Source File: DemandFetcherTest.java    From prebid-mobile-android with Apache License 2.0 6 votes vote down vote up
@Test
public void testBaseConditions() throws Exception {
    PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
    PublisherAdRequest request = builder.build();
    DemandFetcher demandFetcher = new DemandFetcher(request);
    demandFetcher.setPeriodMillis(0);
    HashSet<AdSize> sizes = new HashSet<>();
    sizes.add(new AdSize(300, 250));
    RequestParams requestParams = new RequestParams("12345", AdType.BANNER, sizes);
    demandFetcher.setRequestParams(requestParams);
    assertEquals(DemandFetcher.STATE.STOPPED, FieldUtils.readField(demandFetcher, "state", true));
    demandFetcher.start();
    assertEquals(DemandFetcher.STATE.RUNNING, FieldUtils.readField(demandFetcher, "state", true));
    ShadowLooper fetcherLooper = Shadows.shadowOf(demandFetcher.getHandler().getLooper());
    fetcherLooper.runOneTask();
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    demandFetcher.destroy();
    assertEquals(DemandFetcher.STATE.DESTROYED, FieldUtils.readField(demandFetcher, "state", true));
}
 
Example #7
Source File: SpliceDefaultCompactor.java    From spliceengine with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 * This only overwrites favored nodes when there are none supplied.  I believe in later versions the favoredNodes are
 * populated for region groups.  When this happens, we will pass those favored nodes along.  Until then, we attempt to put the local
 * node in the favored nodes since sometimes Spark Tasks will run compactions remotely.
 *
 * @return
 * @throws IOException
 */
protected InetSocketAddress[] getFavoredNodes() throws IOException {
    try {
        RegionServerServices rsServices = (RegionServerServices) FieldUtils.readField(((HStore) store).getHRegion(), "rsServices", true);
        InetSocketAddress[] returnAddresses = (InetSocketAddress[]) MethodUtils.invokeMethod(rsServices,"getFavoredNodesForRegion",store.getRegionInfo().getEncodedName());
        if ( (returnAddresses == null || returnAddresses.length == 0)
                && store.getFileSystem() instanceof HFileSystem
                && ((HFileSystem)store.getFileSystem()).getBackingFs() instanceof DistributedFileSystem) {
            String[] txvr = conf.get("dfs.datanode.address").split(":"); // hack
            if (txvr.length == 2) {
                returnAddresses = new InetSocketAddress[1];
                returnAddresses[0] = new InetSocketAddress(hostName, Integer.parseInt(txvr[1]));
            }
            else {
                SpliceLogUtils.warn(LOG,"dfs.datanode.address is expected to have form hostname:port but is %s",txvr);
            }
        }
        return returnAddresses;
    } catch (Exception e) {
        SpliceLogUtils.error(LOG,e);
        throw new IOException(e);
    }

}
 
Example #8
Source File: RqueueMessageConfigTest.java    From rqueue with Apache License 2.0 6 votes vote down vote up
@Test
public void rqueueMessageSenderWithMessageConverters() throws IllegalAccessException {
  SimpleRqueueListenerContainerFactory factory = new SimpleRqueueListenerContainerFactory();
  MessageConverter messageConverter = new GenericMessageConverter();
  RqueueListenerConfig messageConfig = new RqueueListenerConfig();
  factory.setMessageConverters(Collections.singletonList(messageConverter));
  FieldUtils.writeField(messageConfig, "simpleRqueueListenerContainerFactory", factory, true);
  factory.setRedisConnectionFactory(mock(RedisConnectionFactory.class));
  assertNotNull(messageConfig.rqueueMessageSender(rqueueMessageTemplate));
  RqueueMessageSender messageSender = messageConfig.rqueueMessageSender(rqueueMessageTemplate);
  boolean messageConverterIsConfigured = false;
  for (MessageConverter converter : messageSender.getMessageConverters()) {
    messageConverterIsConfigured =
        messageConverterIsConfigured || converter.hashCode() == messageConverter.hashCode();
  }
  assertTrue(messageConverterIsConfigured);
}
 
Example #9
Source File: EmbeddedAttributesMappingProcessor.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public void process(MappingProcessorContext context) {
    DatabaseMapping mapping = context.getMapping();
    if (mapping instanceof AggregateObjectMapping) {
        ClassDescriptor descriptor = mapping.getDescriptor();
        Field referenceField =
                FieldUtils.getFieldsListWithAnnotation(descriptor.getJavaClass(), EmbeddedParameters.class)
                        .stream().filter(f -> f.getName().equals(mapping.getAttributeName())).findFirst().orElse(null);
        if (referenceField != null) {
            EmbeddedParameters embeddedParameters =
                    referenceField.getAnnotation(EmbeddedParameters.class);
            if (!embeddedParameters.nullAllowed())
                ((AggregateObjectMapping) mapping).setIsNullAllowed(false);
        }
    }
}
 
Example #10
Source File: BeanConvertUtil.java    From MicroCommunity with Apache License 2.0 6 votes vote down vote up
private static void objectFieldsPutMap(Object dstBean, BeanMap beanMap, Map orgMap) {
    //Field[] fields = dstBean.getClass().getDeclaredFields();
    Field[] fields = FieldUtils.getAllFields(dstBean.getClass());
    for (Field field : fields) {
        if (!orgMap.containsKey(field.getName())) {
            continue;
        }
        Class dstClass = field.getType();
        //System.out.println("字段类型" + dstClass);

        Object value = orgMap.get(field.getName());
        //String 转date
        Object tmpValue = Java110Converter.getValue(value, dstClass);
        beanMap.put(field.getName(), tmpValue);
    }
}
 
Example #11
Source File: TestTwilioAckScriptHandler.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
   super.setUp();
   builder = buildParameters(null);
   FieldUtils.writeField(handler, "twilioAccountAuth", "AUTHKEY", true);

   sig = Base64.encodeToString(HmacUtils.hmacSha1 ("AUTHKEY", TwilioHelper.PROTOCOL_HTTPS + "somehost" + builder.toString()));
   EasyMock.expect(request.getUri()).andReturn(builder.toString()).anyTimes();
   EasyMock.expect(request.getMethod()).andReturn(HttpMethod.GET);
   EasyMock.expect(request.headers()).andReturn(httpHeaders).anyTimes();
   
   EasyMock.expect(httpHeaders.contains(TwilioHelper.SIGNATURE_HEADER_KEY)).andReturn(true).anyTimes();
   EasyMock.expect(httpHeaders.get(TwilioHelper.SIGNATURE_HEADER_KEY)).andReturn(sig).anyTimes();
   EasyMock.expect(httpHeaders.get(TwilioHelper.HOST_HEADER_KEY)).andReturn("somehost").anyTimes();
   EasyMock.expect(personDAO.findById(personID)).andReturn(person);
   EasyMock.expect(placeDAO.findById(placeId)).andReturn(place);
   EasyMock.expect(populationCacheMgr.getPopulationByPlaceId(EasyMock.anyObject(UUID.class))).andReturn(Population.NAME_GENERAL).anyTimes();
}
 
Example #12
Source File: EntityManagerContainer.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void check(JpaObject jpa, CheckRemoveType checkRemoveType) throws Exception {
	for (Entry<Field, CheckRemove> entry : entityManagerContainerFactory.getCheckRemoveFields(jpa.getClass())
			.entrySet()) {
		Field field = entry.getKey();
		CheckRemove checkRemove = entry.getValue();
		FieldType fieldType = this.getFieldType(entry.getKey());
		// Object object = jpa.get(field.getName());
		Object object = FieldUtils.readField(field, jpa, true);
		switch (fieldType) {
			case stringValue:
				this.removeChecker.stringValue.check(field, null == object ? null : Objects.toString(object), jpa,
						checkRemove, checkRemoveType);
				break;
			case stringValueList:
				this.removeChecker.stringValueList.check(field, null == object ? null : (List<String>) object, jpa,
						checkRemove, checkRemoveType);
				break;
			default:
				break;
		}
	}
}
 
Example #13
Source File: ResourceResolverAssertions.java    From ogham with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static <T> Set<T> findResolvers(RelativeResolver resolver, Class<T> resolverClass) {
	try {
		Set<T> found = new HashSet<>();
		if (resolverClass.isAssignableFrom(resolver.getClass())) {
			found.add((T) resolver);
		}
		ResourceResolver delegate = (ResourceResolver) FieldUtils.readField(resolver, "delegate", true);
		if (resolverClass.isAssignableFrom(resolver.getActualResourceResolver().getClass())) {
			found.add((T) delegate);
		}
		return found;
	} catch (IllegalAccessException e) {
		throw new IllegalStateException("Failed to get 'delegate' field of RelativeResolver", e);
	}
}
 
Example #14
Source File: AdUnitSuccessorTest.java    From prebid-mobile-android with Apache License 2.0 5 votes vote down vote up
@Test
public void testBannerAdUnitCreation() throws Exception {
    BannerAdUnit adUnit = new BannerAdUnit("123456", 320, 50);
    assertEquals(1, adUnit.getSizes().size());
    assertEquals("123456", FieldUtils.readField(adUnit, "configId", true));
    assertEquals(AdType.BANNER, FieldUtils.readField(adUnit, "adType", true));
    assertEquals(0, FieldUtils.readField(adUnit, "periodMillis", true));
}
 
Example #15
Source File: ApiBuilder.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private List<String> listCopierCopyFields(Class<?> clz) {
	try {
		Object o = FieldUtils.readStaticField(clz, "copier", true);
		WrapCopier copier = (WrapCopier) o;
		return copier.getCopyFields();
	} catch (Exception e) {
		return null;
	}
}
 
Example #16
Source File: DataChangeListenerTestBase.java    From ovsdb with Eclipse Public License 1.0 5 votes vote down vote up
static final void setFinalStatic(final Class<?> cls, final String fieldName, final Object newValue)
        throws SecurityException, ReflectiveOperationException {
    Field[] fields = FieldUtils.getAllFields(cls);
    for (Field field : fields) {
        if (fieldName.equals(field.getName())) {
            field.setAccessible(true);
            Field modifiersField = Field.class.getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
            field.set(null, newValue);
            break;
        }
    }
}
 
Example #17
Source File: PlainPermissionManagerTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void cleanAuthenticationInfoTest() throws IllegalAccessException {
    // PlainPermissionManager.addPlainAccessResource(plainAccessResource);
    Map<String, List<PlainAccessResource>> plainAccessResourceMap = (Map<String, List<PlainAccessResource>>) FieldUtils.readDeclaredField(plainPermissionManager, "plainAccessResourceMap", true);
    Assert.assertFalse(plainAccessResourceMap.isEmpty());

    plainPermissionManager.clearPermissionInfo();
    plainAccessResourceMap = (Map<String, List<PlainAccessResource>>) FieldUtils.readDeclaredField(plainPermissionManager, "plainAccessResourceMap", true);
    Assert.assertTrue(plainAccessResourceMap.isEmpty());
    // RemoveDataVersionFromYamlFile("src/test/resources/conf/plain_acl.yml");
}
 
Example #18
Source File: Describe.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private List<String> listCopierEraseFields(Class<?> clz) {
	try {
		Object o = FieldUtils.readStaticField(clz, "copier", true);
		WrapCopier copier = (WrapCopier) o;
		return copier.getEraseFields();
	} catch (Exception e) {
		return null;
	}
}
 
Example #19
Source File: JsonCompareUtil.java    From soundwave with Apache License 2.0 5 votes vote down vote up
public static <E> Map<String, Object[]> findDiff(E inst1, E inst2, Set<String> excludedFields)
    throws Exception {
  Preconditions.checkNotNull(inst1);
  Preconditions.checkNotNull(inst2);

  HashMap<String, Object[]> diff = new HashMap<>();
  //Compare all fields with @JsonProperty
  for (Field f : FieldUtils.getFieldsWithAnnotation(inst1.getClass(), JsonProperty.class)) {
    String name = f.getAnnotation(JsonProperty.class).value();
    if (excludedFields.contains(name)) {
      continue;
    }
    f.setAccessible(true);
    Object left = f.get(inst1);
    Object right = f.get(inst2);
    if (left == null && right == null) {
      continue;
    }

    if (f.getType().isArray()) {
      if (!Arrays.equals((Object[]) left, (Object[]) right)) {
        logger.info("Found diff on property {}", name);
        diff.put(name, new Object[]{left, right});
      }
    } else if (f.getType() == Map.class) {
      Map<String, Object[]> details = new HashMap<>();
      getDetailsDiff((Map) left, (Map) right, details, name);
      for (Map.Entry<String, Object[]> entry : details.entrySet()) {
        diff.put(entry.getKey(), entry.getValue());
      }
    } else {
      if (left == null || !left.equals(right)) {
        logger.info("Found diff on property {}", name);
        diff.put(name, new Object[]{left, right});
      }
    }
  }
  return diff;
}
 
Example #20
Source File: Describe.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
/** 判断字段是否在Wi中但是没有在Entity类中说明是Wi新增字段,需要进行描述 */
private Boolean inWiNotInEntity(String field, Class<?> clz) {
	try {
		Object o = FieldUtils.readStaticField(clz, "copier", true);
		WrapCopier copier = (WrapCopier) o;
		if ((null != FieldUtils.getField(copier.getOrigClass(), field, true))
				&& (null == FieldUtils.getField(copier.getDestClass(), field, true))) {
			return true;
		}
		return false;
	} catch (Exception e) {
		return null;
	}
}
 
Example #21
Source File: OghamPropertiesOnlyTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void sendGridPropertiesDefinedInAppPropertiesOrInSystemPropertiesShouldOverrideOghamDefaultProperties() throws IllegalAccessException {
	SendGridV4Sender sender = builder.email().sender(SendGridV4Builder.class).build();
	DelegateSendGridClient delegate = (DelegateSendGridClient) sender.getDelegate();
	SendGrid sendGrid = (SendGrid) FieldUtils.readField(delegate, "delegate", true);
	assertThat(SendGridUtils.getApiKey(sendGrid), equalTo("ogham"));
	assertThat(sendGrid, not(sameInstance(springSendGridClient)));
}
 
Example #22
Source File: ConfigUtils.java    From FROST-Server with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Return a mapping of config tag value and default value for any field, of
 * the given Object, annotated with {@link DefaultValueInt}.
 *
 * @param <T> The class that extends ConfigDefaults.
 * @param target The class to get the config fields for.
 * @return Mapping of config tag value and default value
 */
public static <T extends ConfigDefaults> Map<String, Integer> getConfigDefaultsInt(Class<T> target) {
    Map<String, Integer> configDefaults = new HashMap<>();
    List<Field> fields = FieldUtils.getFieldsListWithAnnotation(target, DefaultValueInt.class);
    for (Field f : fields) {
        try {
            configDefaults.put(
                    f.get(target).toString(),
                    f.getAnnotation(DefaultValueInt.class).value());
        } catch (IllegalAccessException exc) {
            LOGGER.warn(UNABLE_TO_ACCESS_FIELD_ON_OBJECT, f.getName(), target);
        }
    }
    return configDefaults;
}
 
Example #23
Source File: WrapCopierFactory.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private static List<String> getAllFieldNames(Class<?> cls) throws Exception {
	List<String> names = new ArrayList<>();
	for (Field field : FieldUtils.getAllFields(cls)) {
		names.add(field.getName());
	}
	return names;
}
 
Example #24
Source File: SoftDeleteJoinExpressionProvider.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected Expression processOneToOneMapping(OneToOneMapping mapping) {
    ClassDescriptor descriptor = mapping.getDescriptor();
    Field referenceField = FieldUtils.getAllFieldsList(descriptor.getJavaClass())
            .stream().filter(f -> f.getName().equals(mapping.getAttributeName()))
            .findFirst().orElse(null);
    if (SoftDelete.class.isAssignableFrom(mapping.getReferenceClass()) && referenceField != null) {
        OneToOne oneToOne = referenceField.getAnnotation(OneToOne.class);
        if (oneToOne != null && !Strings.isNullOrEmpty(oneToOne.mappedBy())) {
            return new ExpressionBuilder().get("deleteTs").isNull();
        }
    }
    return null;
}
 
Example #25
Source File: TestOptimisticByteOutput.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testRopeByteStringWithZeroOnLeft() throws Exception {
  ByteString literal = ByteString.copyFrom(smallData);

  ByteString data = (ByteString) NEW_ROPE_BYTE_STRING_INSTANCE.invoke(null, ByteString.EMPTY, literal);

  OptimisticByteOutput byteOutput = new OptimisticByteOutput(smallData.length);
  UnsafeByteOperations.unsafeWriteTo(data, byteOutput);

  byte[] array = (byte[]) FieldUtils.readField(literal, "bytes", true);
  assertArrayEquals(smallData, byteOutput.toByteArray());
  assertSame(array, byteOutput.toByteArray());
}
 
Example #26
Source File: JpaObject.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public List<String> restrictFlagValues() throws Exception {
	List<String> values = this.flagValues();
	for (Field f : FieldUtils.getFieldsListWithAnnotation(this.getClass(), RestrictFlag.class)) {
		values.add(PropertyUtils.getProperty(this, f.getName()).toString());
	}
	return ListTools.trim(values, true, true);
}
 
Example #27
Source File: TestTwilioAckEventHandler.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Test
public void testRespondSignatureValidationFailedValidationOff() throws Exception {
   buildMocks();
   expectAuditLog(AuditEventState.DELIVERED);
   replay();
   FieldUtils.writeField(handler, "twilioAccountAuth", "xyx", true);
   FieldUtils.writeField(handler, "twilioVerifyAuth", false, true);
   FullHttpResponse response = handler.respond(request, ctx);
   assertEquals(HttpResponseStatus.NO_CONTENT,response.getStatus());
}
 
Example #28
Source File: AtlasAapt.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
protected ProcessInfoBuilder makePackageProcessBuilder(AaptPackageConfig config) throws AaptException {
    ProcessInfoBuilder processInfoBuilder = super.makePackageProcessBuilder(config);

    List<String> args = null;
    try {
        args = (List<String>) FieldUtils.readField(processInfoBuilder, "mArgs", true);
    } catch (IllegalAccessException e) {
        throw new GradleException("getargs exception", e);
    }

    //args.remove("--no-version-vectors");
    //
    ////Does not generate manifest_keep.txt file
    //int indexD = args.indexOf("-D");
    //if (indexD > 0){
    //    args.remove(indexD);
    //    args.remove(indexD);
    //}

    //Join the outputs of the R.txt file
    String sybolOutputDir = config.getSymbolOutputDir().getAbsolutePath();
    if (!args.contains("--output-text-symbols") && null != sybolOutputDir) {
        args.add("--output-text-symbols");
        args.add(sybolOutputDir);
    }

    return processInfoBuilder;
}
 
Example #29
Source File: TestOptimisticByteOutput.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testRopeByteStringWithZeroOnRight() throws Exception {
  ByteString literal = ByteString.copyFrom(smallData);

  ByteString data = (ByteString) NEW_ROPE_BYTE_STRING_INSTANCE.invoke(null, literal, ByteString.EMPTY);

  OptimisticByteOutput byteOutput = new OptimisticByteOutput(smallData.length);
  UnsafeByteOperations.unsafeWriteTo(data, byteOutput);

  byte[] array = (byte[]) FieldUtils.readField(literal, "bytes", true);
  assertArrayEquals(smallData, byteOutput.toByteArray());
  assertSame(array, byteOutput.toByteArray());
}
 
Example #30
Source File: HttpClientUtilTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void assertSSLHostnameVerifier(Class<? extends HostnameVerifier> expected,
                                       SocketFactoryRegistryProvider provider) {
  ConnectionSocketFactory socketFactory = provider.getSocketFactoryRegistry().lookup("https");
  assertNotNull("unable to lookup https", socketFactory);
  assertTrue("socketFactory is not an SSLConnectionSocketFactory: " + socketFactory.getClass(),
             socketFactory instanceof SSLConnectionSocketFactory);
  SSLConnectionSocketFactory sslSocketFactory = (SSLConnectionSocketFactory) socketFactory;
  try {
    Object hostnameVerifier = FieldUtils.readField(sslSocketFactory, "hostnameVerifier", true);
    assertNotNull("sslSocketFactory has null hostnameVerifier", hostnameVerifier);
    assertEquals("sslSocketFactory does not have expected hostnameVerifier impl",
                 expected, hostnameVerifier.getClass());
  } catch (IllegalAccessException e) {
    throw new AssertionError("Unexpected access error reading hostnameVerifier field", e);
  }
}