Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Identifiers #3939

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@ public class InputStreamSource implements StreamSource {
// re-read it.

protected BufferedInputStream inputStream;
protected byte[] bytes;
protected byte[] byteArray;

public InputStreamSource(InputStream inputStream) {
this.inputStream = new BufferedInputStream(inputStream);
}

@Override
public InputStream getInputStream() {
if (bytes == null) {
if (byteArray == null) {
try {
bytes = getBytesFromInputStream(inputStream);
byteArray = getBytesFromInputStream(inputStream);
} catch (IOException e) {
throw new FlowableException("Could not read from inputstream", e);
}
}
return new BufferedInputStream(new ByteArrayInputStream(bytes));
return new BufferedInputStream(new ByteArrayInputStream(byteArray));
}

@Override
public String toString() {
return "InputStream";
}

public byte[] getBytesFromInputStream(InputStream inStream) throws IOException {
long length = inStream.available();
public byte[] getBytesFromInputStream(InputStream inputStream) throws IOException {
long length = inputStream.available();
byte[] bytes = new byte[(int) length];

int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead = inStream.read(bytes, offset, bytes.length - offset)) >= 0) {
while (offset < bytes.length && (numRead = inputStream.read(bytes, offset, bytes.length - offset)) >= 0) {
offset += numRead;
}

Expand All @@ -70,7 +70,7 @@ public byte[] getBytesFromInputStream(InputStream inStream) throws IOException {
}

// Close the input stream and return bytes
inStream.close();
inputStream.close();
return bytes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ public class ServiceConfiguratorTest {

@Test
public void testNoServiceConfigurators() {
AtomicBoolean beforeInit = new AtomicBoolean(false);
AtomicBoolean afterInit = new AtomicBoolean(false);
AtomicBoolean beforeInitialization = new AtomicBoolean(false);
AtomicBoolean afterInitialization = new AtomicBoolean(false);

TestServiceConfiguration serviceConfig = new TestServiceConfiguration("test");
serviceConfig.init();

assertThat(beforeInit.get()).isFalse();
assertThat(afterInit.get()).isFalse();
assertThat(beforeInitialization.get()).isFalse();
assertThat(afterInitialization.get()).isFalse();
}

@Test
public void testSetServiceConfigurators() {
AtomicBoolean beforeInit = new AtomicBoolean(false);
AtomicBoolean afterInit = new AtomicBoolean(false);

TestServiceConfiguration serviceConfig = new TestServiceConfiguration("test");
serviceConfig.setConfigurators(List.of(new ServiceConfigurator<TestServiceConfiguration>() {
TestServiceConfiguration serviceConfiguration = new TestServiceConfiguration("test");
serviceConfiguration.setConfigurators(List.of(new ServiceConfigurator<TestServiceConfiguration>() {

@Override
public void beforeInit(TestServiceConfiguration service) {
Expand All @@ -40,7 +40,7 @@ public void afterInit(TestServiceConfiguration service) {
}
}));

serviceConfig.init();
serviceConfiguration.init();

assertThat(beforeInit.get()).isTrue();
assertThat(afterInit.get()).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ public void testExecutionListenerFieldInjection() {

ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionListenersProcess", variables);

Object varSetByListener = runtimeService.getVariable(processInstance.getId(), "var");
assertNotNull(varSetByListener);
assertTrue(varSetByListener instanceof String);
Object variableSetByListener = runtimeService.getVariable(processInstance.getId(), "var");
assertNotNull(variableSetByListener);
assertTrue(variableSetByListener instanceof String);

// Result is a concatenation of fixed injected field and injected expression
assertEquals("Yes, I am listening!", varSetByListener);
assertEquals("Yes, I am listening!", variableSetByListener);
}

@Deployment(resources = { "org/activiti/examples/bpmn/executionlistener/ExecutionListenersCurrentActivity.bpmn20.xml" })
Expand Down