/** 정해진 시간에 호출이 완료되는 경우 timeout없이 올바른 리턴값을 줘야한다. */ @Test public void shouldReturnValueWithoutTimeout() { ExecuteFunction<String, String> func = new ExecuteFunction<String, String>() { public String apply(String t) { try { Thread.sleep(100); } catch (Exception e) { } return t; } }; String expected = "hello"; ExecuteResult<String> result = timeoutSvc.executeInTransaction(func, expected, 1000); assertThat(result.getReturnObject()).isEqualTo(expected); }
/** 지정된 시간 내에 처리가 완료되면 트랜잭션은 commit이 되야 한다. */ @Test public void shouldCommitWhenExecutedInTime() { ExecuteFunction<Employee, Integer> func = new ExecuteFunction<Employee, Integer>() { public Integer apply(Employee emp) { return empService.addNewEmployee(emp); } }; empService.deleteById("committedInTime"); Employee emp = new Employee(); emp.setId("committedInTime"); emp.setName("committedInTime"); ExecuteResult<Integer> result = timeoutSvc.<Employee, Integer>executeInTransaction(func, emp, 1000); assertThat(result.getReturnObject()).isEqualTo(1); Employee actual = empService.findById("committedInTime"); assertThat(actual).isNotNull(); assertThat(actual.getId()).isEqualTo("committedInTime"); }
public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof ExecuteResult)) return false; ExecuteResult other = (ExecuteResult) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc == obj); } __equalsCalc = obj; boolean _equals; _equals = true && ((this.errors == null && other.getErrors() == null) || (this.errors != null && java.util.Arrays.equals(this.errors, other.getErrors()))) && ((this.id == null && other.getId() == null) || (this.id != null && this.id.equals(other.getId()))) && ((this.success == null && other.getSuccess() == null) || (this.success != null && this.success.equals(other.getSuccess()))); __equalsCalc = null; return _equals; }