Example usage for org.apache.commons.lang3.builder ToStringBuilder reflectionToString

List of usage examples for org.apache.commons.lang3.builder ToStringBuilder reflectionToString

Introduction

In this page you can find the example usage for org.apache.commons.lang3.builder ToStringBuilder reflectionToString.

Prototype

public static String reflectionToString(final Object object) 

Source Link

Document

Uses ReflectionToStringBuilder to generate a toString for the specified object.

Usage

From source file:com.raffaele.squarecash4glass.CVVConfirmActivity.java

/**
 * Recommended "safe" way to open the camera.
 * /* www  .j  a v a  2 s  .  c om*/
 * @param view
 * @return
 */
private boolean safeCameraOpenInView(View view) {
    boolean qOpened = false;
    releaseCameraAndPreview();
    mCamera = getCameraInstance();
    qOpened = (mCamera != null);

    if (qOpened == true) {
        mPreview = new CameraPreview(getBaseContext(), mCamera, view);
        FrameLayout preview = (FrameLayout) view.findViewById(R.id.camera_preview);
        preview.addView(mPreview);
        mPreview.startCameraPreview();
        Log.i(TAG, "camera parameters:" + mCamera.getParameters());
        Log.i(TAG, "camera current size:"
                + ToStringBuilder.reflectionToString(mCamera.getParameters().getPictureSize()));
        Log.i(TAG,
                "camera supported sizes:" + ToStringBuilder.reflectionToString(
                        mCamera.getParameters().getSupportedPictureSizes().toArray(),
                        new RecursiveToStringStyle()));
        cameraAvailable = true;
    }
    Log.i(TAG, "safeCameraOpenInView completed.");
    return qOpened;
}

From source file:eu.openanalytics.rsb.rservi.RmiRServiInstanceProvider.java

private void initializeRServiClientPool(final Config config) {
    final KeyedPoolableObjectFactory<RServiPoolKey, PooledRServiWrapper> factory = new BaseKeyedPoolableObjectFactory<RServiPoolKey, PooledRServiWrapper>() {
        @Override/*w  w  w  .  ja va  2  s.  c  om*/
        public PooledRServiWrapper makeObject(final RServiPoolKey key) throws Exception {
            final RServi rServi = RServiUtil.getRServi(key.getAddress(), key.getClientId());
            return new PooledRServiWrapper(rServiPool, key, rServi);
        }

        @Override
        public void destroyObject(final RServiPoolKey key, final PooledRServiWrapper rServi) throws Exception {
            rServi.destroy();
        }

        @Override
        public boolean validateObject(final RServiPoolKey key, final PooledRServiWrapper rServi) {
            if (rServi.isClosed()) {
                return false;
            }

            if (rServi.hasError() || configuration
                    .getRServiClientPoolValidationStrategy() == RServiClientPoolValidationStrategy.FULL) {
                final boolean responding = Util.isRResponding(rServi);

                if (rServi.hasError() && LOGGER.isInfoEnabled()) {
                    LOGGER.info(String.format("RServi @ %s has been found %svalid after error",
                            key.getAddress(), responding ? "" : "in"));
                }

                if (responding) {
                    rServi.resetError();
                }

                return responding;
            } else {
                return true;
            }
        }
    };

    rServiPool = new GenericKeyedObjectPoolFactory<RServiPoolKey, PooledRServiWrapper>(factory, config)
            .createPool();
    LOGGER.info("RServi pool instantiated and configured with: " + ToStringBuilder.reflectionToString(config));
}

From source file:com.thoughtworks.go.server.dao.PipelineSqlMapDaoCachingTest.java

@Test
public void loadHistory_shouldCloneResultSoThatModificationsDoNotAffectTheCachedObjects() {
    PipelineInstanceModel pipeline = new PipelineInstanceModel("pipeline", -2, "label",
            BuildCause.createManualForced(), new StageInstanceModels());
    when(mockTemplate.queryForObject(eq("getPipelineHistoryById"), any())).thenReturn(pipeline);
    PipelineInstanceModel loaded;//from  w  w w  . j a  va  2s  . c om
    loaded = pipelineDao.loadHistory(99);
    loaded = pipelineDao.loadHistory(99);
    assertNotSame(pipeline, loaded);
    assertTrue(
            ToStringBuilder.reflectionToString(loaded) + " not equal to\n"
                    + ToStringBuilder.reflectionToString(pipeline),
            EqualsBuilder.reflectionEquals(loaded, pipeline));
    verify(mockTemplate, times(1)).queryForObject(eq("getPipelineHistoryById"), any());
}

From source file:net.d53.syman.web.controller.PatientController.java

@RequestMapping(value = "/api/auth", method = RequestMethod.POST)
@ResponseBody/* www.  jav a2s. com*/
public String APIauthenticate(@RequestParam String username, @RequestParam String password,
        HttpServletRequest request, HttpServletResponse response) {
    String token = null;
    UsernamePasswordAuthenticationToken authenticationRequest = new UsernamePasswordAuthenticationToken(
            username, password);

    authenticationRequest.setDetails(APIAuthenticationToken.API_TOKEN_IDENTIFIER);

    try {
        APIAuthenticationToken res = (APIAuthenticationToken) authenticationManager
                .authenticate(authenticationRequest);
        LOGGER.info(ToStringBuilder.reflectionToString(res));
        if (res != null) {
            token = res.getCredentials().toString();
            LOGGER.info("Generated token " + token);
            SecurityContext context = SecurityContextHolder.getContext();
            context.setAuthentication(res);
            this.securityContextRepository.saveContext(context, request, response);
        } else {
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        }
    } catch (AuthenticationException e) {
        LOGGER.info("Authentication error: " + e.getMessage());
        SecurityContextHolder.clearContext();
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
    return token;
}

From source file:com.thoughtworks.go.server.dao.PipelineSqlMapDaoCachingTest.java

@Test
public void loadActivePipelines_shouldCacheResult() {
    final String pipelineName = "pipeline";
    CruiseConfig mockCruiseConfig = mock(BasicCruiseConfig.class);
    GoConfigDao mockconfigFileDao = mock(GoConfigDao.class);
    when(mockconfigFileDao.load()).thenReturn(mockCruiseConfig);
    when(mockCruiseConfig.getAllPipelineNames())
            .thenReturn(Arrays.asList(new CaseInsensitiveString(pipelineName)));

    //need to mock configfileDao for this test
    pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate,
            null, transactionSynchronizationManager, null, mockconfigFileDao, null, mock(SessionFactory.class),
            timeProvider);/* www .j  a  v  a2s. com*/
    pipelineDao.setSqlMapClientTemplate(mockTemplate);

    PipelineInstanceModel pipeline = new PipelineInstanceModel(pipelineName, -2, "label",
            BuildCause.createManualForced(), new StageInstanceModels());
    PipelineInstanceModels pims = PipelineInstanceModels.createPipelineInstanceModels(pipeline);
    when(mockTemplate.queryForList("allActivePipelines")).thenReturn((List) pims);
    when(mockTemplate.queryForObject(eq("getPipelineHistoryById"), any())).thenReturn(pipeline);
    PipelineInstanceModels loaded;
    loaded = pipelineDao.loadActivePipelines();
    loaded = pipelineDao.loadActivePipelines();
    assertNotSame(pipeline, loaded);
    assertTrue(
            ToStringBuilder.reflectionToString(loaded) + " not equal to\n"
                    + ToStringBuilder.reflectionToString(pipeline),
            EqualsBuilder.reflectionEquals(loaded, pims));
    verify(mockTemplate, times(1)).queryForList("allActivePipelines");
    verify(mockTemplate, times(1)).queryForObject(eq("getPipelineHistoryById"), any());
    verify(mockconfigFileDao, times(2)).load();
    verify(mockCruiseConfig, times(2)).getAllPipelineNames();
}

From source file:com.funtl.framework.smoke.core.modules.act.service.ActTaskService.java

/**
 * ???/*from   w w w.  j ava2 s  .co  m*/
 *
 * @param processInstance
 * @return
 */
private Task getCurrentTaskInfo(ProcessInstance processInstance) {
    Task currentTask = null;
    try {
        String activitiId = (String) PropertyUtils.getProperty(processInstance, "activityId");
        logger.debug("current activity id: {}", activitiId);

        currentTask = taskService.createTaskQuery().processInstanceId(processInstance.getId())
                .taskDefinitionKey(activitiId).singleResult();
        logger.debug("current task for processInstance: {}", ToStringBuilder.reflectionToString(currentTask));

    } catch (Exception e) {
        logger.error("can not get property activityId from processInstance: {}", processInstance);
    }
    return currentTask;
}

From source file:org.apache.alert.coordinator.NodataMetadataGeneratorTest.java

@Test
public void testNormal() throws Exception {
    StreamDefinition sd = createStreamDefinitionWithNodataAlert();
    Map<String, StreamDefinition> streamDefinitionsMap = new HashMap<String, StreamDefinition>();
    streamDefinitionsMap.put(sd.getStreamId(), sd);

    Map<String, Kafka2TupleMetadata> kafkaSources = new HashMap<String, Kafka2TupleMetadata>();
    Map<String, PolicyDefinition> policies = new HashMap<String, PolicyDefinition>();
    Map<String, Publishment> publishments = new HashMap<String, Publishment>();

    generator.execute(config, streamDefinitionsMap, kafkaSources, policies, publishments);

    Assert.assertEquals(2, kafkaSources.size());

    kafkaSources.forEach((key, value) -> {
        LOG.info("KafkaSources > {}: {}", key, ToStringBuilder.reflectionToString(value));
    });/*from w w w . java  2s. com*/

    Assert.assertEquals(2, policies.size());

    policies.forEach((key, value) -> {
        LOG.info("Policies > {}: {}", key, ToStringBuilder.reflectionToString(value));
    });

    Assert.assertEquals(4, publishments.size());

    publishments.forEach((key, value) -> {
        LOG.info("Publishments > {}: {}", key, ToStringBuilder.reflectionToString(value));
    });
}

From source file:org.apache.cxf.xjc.runtime.JAXBElementToStringStyleTest.java

@Test
public void testToStringDefault() throws Exception {

    String ts = ToStringBuilder.reflectionToString(h);

    validateHolderString(ts);/*from  w ww . ja v a  2 s .  c  om*/

    // JAXBElement contents not present
    Assert.assertTrue("has no value", ts.indexOf("value") == -1);
    Assert.assertTrue("has no bv", ts.indexOf("bv") == -1);

}

From source file:org.apache.jmeter.save.SaveService.java

/**
 * //  w w w  . ja v  a 2 s . co m
 * @param result SampleResult
 * @return String debugging information
 */
private static String showDebuggingInfo(SampleResult result) {
    try {
        return "class:" + result.getClass() + ",content:" + ToStringBuilder.reflectionToString(result);
    } catch (Exception e) {
        return "Exception occured creating debug from event, message:" + e.getMessage();
    }
}

From source file:org.diorite.cfg.system.elements.TemplateElement.java

private String getExceptionMessage(final Object obj, final String s) {
    if (s == null) {
        return "Can't convert object (" + obj.getClass().getName() + ") to " + this.fieldType.getName() + ": "
                + ToStringBuilder.reflectionToString(obj);
    }//from  w  w  w.ja va  2  s .co m
    return "Can't convert object (" + obj.getClass().getName() + ") to " + this.fieldType.getName()
            + ", caused by: '" + s + "', object: " + ToStringBuilder.reflectionToString(obj);
}