org.springframework.batch.item.ExecutionContext.putDouble()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(70)

本文整理了Java中org.springframework.batch.item.ExecutionContext.putDouble()方法的一些代码示例,展示了ExecutionContext.putDouble()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext.putDouble()方法的具体详情如下:
包路径:org.springframework.batch.item.ExecutionContext
类名称:ExecutionContext
方法名:putDouble

ExecutionContext.putDouble介绍

[英]Add a Double value to the context.
[中]在上下文中添加一个双精度值。

代码示例

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testGetNamedDoubleJobParameters() throws Exception {
  stepExecution.getExecutionContext().putDouble("foo",11.1);
  extractor.setKeys(new String[] {"foo(double)"});
  JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
  assertEquals("{foo=11.1}", jobParameters.toString());
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testUseParentParameters() throws Exception {
  JobExecution jobExecution = new JobExecution(0L, new JobParametersBuilder()
      .addString("parentParam", "val")
      .toJobParameters());
  StepExecution stepExecution = new StepExecution("step", jobExecution);
  stepExecution.getExecutionContext().putDouble("foo", 11.1);
  extractor.setKeys(new String[] {"foo(double)"});
  JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
  String jobParams = jobParameters.toString();
  assertTrue("Job parameters must contain parentParam=val", jobParams.contains("parentParam=val"));
  assertTrue("Job parameters must contain foo=11.1", jobParams.contains("foo=11.1"));
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testSerialization() {
  TestSerializable s = new TestSerializable();
  s.value = 7;
  context.putString("1", "testString1");
  context.putString("2", "testString2");
  context.putLong("3", 3);
  context.putDouble("4", 4.4);
  context.put("5", s);
  context.putInt("6", 6);
  byte[] serialized = SerializationUtils.serialize(context);
  ExecutionContext deserialized = (ExecutionContext) SerializationUtils.deserialize(serialized);
  assertEquals(context, deserialized);
  assertEquals(7, ((TestSerializable) deserialized.get("5")).value);
}

代码示例来源:origin: spring-projects/spring-batch

@Test
  public void testDontUseParentParameters() throws Exception {
    DefaultJobParametersExtractor extractor = new DefaultJobParametersExtractor();
    extractor.setUseAllParentParameters(false);

    JobExecution jobExecution = new JobExecution(0L, new JobParametersBuilder()
        .addString("parentParam", "val")
        .toJobParameters());

    StepExecution stepExecution = new StepExecution("step", jobExecution);

    stepExecution.getExecutionContext().putDouble("foo", 11.1);
    extractor.setKeys(new String[] {"foo(double)"});
    JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);

    assertEquals("{foo=11.1}", jobParameters.toString());
  }
}

代码示例来源:origin: spring-projects/spring-batch

@Test
public void testNormalUsage() {
  context.putString("1", "testString1");
  context.putString("2", "testString2");
  context.putLong("3", 3);
  context.putDouble("4", 4.4);
  context.putInt("5", 5);
  assertEquals("testString1", context.getString("1"));
  assertEquals("testString2", context.getString("2"));
  assertEquals("defaultString", context.getString("55", "defaultString"));
  assertEquals(4.4, context.getDouble("4"), 0);
  assertEquals(5.5, context.getDouble("55", 5.5), 0);
  assertEquals(3, context.getLong("3"));
  assertEquals(5, context.getLong("55", 5));
  assertEquals(5, context.getInt("5"));
  assertEquals(6, context.getInt("55", 6));
}

相关文章