Skip to content

Commit 0def68f

Browse files
committed
Fixing tests
1 parent 99bf04a commit 0def68f

11 files changed

Lines changed: 248 additions & 46 deletions

File tree

build.gradle

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ java {
2222
}
2323
}
2424

25-
//version = '1.1.0'
25+
version = '1.1.1'
2626

2727
repositories {
2828
flatDir {
@@ -117,16 +117,27 @@ publishing {
117117
}
118118
}
119119

120+
jacoco {
121+
toolVersion = "0.8.10"
122+
}
123+
120124
jacocoTestReport {
121125
reports {
122126
xml.required = true
127+
html.outputLocation = layout.buildDirectory.dir('test-coverage')
128+
dependsOn test // tests are required to run before generating the report
123129
}
124130
}
125131

126-
uberJar {
127-
dependsOn jar
128-
}
129132

130133
test {
134+
finalizedBy jacocoTestReport // report is always generated after tests run
135+
testLogging {
136+
testLogging.showStandardStreams = true
137+
}
131138
useJUnitPlatform()
132-
}
139+
}
140+
141+
uberJar {
142+
dependsOn jar
143+
}

src/main/java/br/unicamp/cst/bindings/ros2java/RosTopicPublisherCodelet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public abstract class RosTopicPublisherCodelet<T extends Message> extends Codele
2727
protected JRos2Client ros2Client;
2828
protected TopicSubmissionPublisher<T> publisher;
2929

30-
public RosTopicPublisherCodelet(String topic, Class<T> messageType) {
30+
public RosTopicPublisherCodelet(String name, String topic, Class<T> messageType) {
3131
this.topic = topic;
3232
this.messageType = messageType;
33-
setName("Ros2Publisher:" + topic);
33+
setName(name);
3434
}
3535

3636
@Override

src/main/java/br/unicamp/cst/bindings/ros2java/RosTopicSubscriberCodelet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public abstract class RosTopicSubscriberCodelet<T extends Message> extends Codel
3030
protected JRos2Client ros2Client;
3131
protected TopicSubscriber<T> subscriber;
3232

33-
public RosTopicSubscriberCodelet(String topic, Class<T> messageType) {
33+
public RosTopicSubscriberCodelet(String name, String topic, Class<T> messageType) {
3434
this.topic = topic;
3535
this.messageType = messageType;
36-
setName("Ros2Subscriber:" + topic);
36+
setName(name);
3737
}
3838

3939
@Override

src/main/java/br/unicamp/cst/bindings/rosjava/RosServiceClientCodelet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class RosServiceClientCodelet<S,T> extends Codelet implements No
4242

4343
protected String messageServiceType;
4444

45-
protected Memory motorMemory;
45+
protected volatile Memory motorMemory;
4646

4747
protected S serviceMessageRequest;
4848

@@ -115,7 +115,7 @@ private void stopRosNode() {
115115
}
116116

117117
@Override
118-
public void accessMemoryObjects() {
118+
public synchronized void accessMemoryObjects() {
119119
int index = 0;
120120

121121
if(motorMemory == null)
@@ -132,7 +132,7 @@ public void calculateActivation() {
132132
}
133133

134134
@Override
135-
public void proc() {
135+
public synchronized void proc() {
136136
if(motorMemory != null
137137
&& motorMemory.getI() != null
138138
&& serviceMessageRequest != null

src/main/java/br/unicamp/cst/bindings/soar/JSoarCodelet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public synchronized Object buildObject(Idea command, String package_with_beans_c
102102
type.cast(commandObject);
103103

104104
} catch (Exception e) {
105-
e.printStackTrace();
105+
//e.printStackTrace();
106+
System.out.println("I was not able to find the class "+package_with_beans_classes + "." + commandType);
106107
}
107108
for (Idea p : command.getL()) {
108109
try {

src/main/java/br/unicamp/cst/bindings/soar/SOARPlugin.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,9 @@ public Object createJavaObject(String classname) {
617617
javaObject = type.newInstance();
618618
type.cast(javaObject);
619619
} catch (Exception e) {
620-
e.printStackTrace();
620+
if (e instanceof java.lang.ClassNotFoundException)
621+
System.out.println("SOARPlugin was not able to create an instance of "+classname+" class ... Class Not Found!!");
622+
else e.printStackTrace();
621623
}
622624
return (javaObject);
623625
}
@@ -694,7 +696,9 @@ public Object convertObject(Object origin, String className) {
694696
return (origin);
695697
}
696698
} catch (Exception e){
697-
e.printStackTrace();
699+
if (e instanceof java.lang.NumberFormatException)
700+
System.out.println("SOARPlugin: The conversion of class "+className+" was not successful! ... NumberFormatException");
701+
else e.printStackTrace();
698702
return null;
699703
}
700704
}

src/test/java/br/unicamp/cst/bindings/ros2java/ROS2_ChatterTopicPublisher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public class ROS2_ChatterTopicPublisher extends RosTopicPublisherCodelet<StringMessage> {
1818

1919
public ROS2_ChatterTopicPublisher(String topic) {
20-
super(topic, StringMessage.class);
20+
super("teste",topic, StringMessage.class);
2121
}
2222

2323
@Override

src/test/java/br/unicamp/cst/bindings/ros2java/ROS2_ChatterTopicSubscriber.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class ROS2_ChatterTopicSubscriber extends RosTopicSubscriberCodelet<StringMessage> {
1717

1818
public ROS2_ChatterTopicSubscriber(String topic) {
19-
super(topic, StringMessage.class);
19+
super("teste",topic, StringMessage.class);
2020
}
2121

2222
@Override

0 commit comments

Comments
 (0)