Commit ef0e34bb authored by Björn Butzin's avatar Björn Butzin
Browse files

Bugfixes: Multicast not allowed crash, test crash during build

jCoAP crashed when multicast was not allowed on a machine: Added Exception Handler, instead of a system failure, a warning is shown that jCoAP runs without multicast support
fixed test setup: some static modifiers crashed the test and thus the build
updated jcoap-core version to 1.1.2
updated dependencies in all projects
renamed all maven artifacts with a prefix "jcoap-" as otherwise generated jars are not identified with jcoap
removed all snapshot endings in version numbers
set all .settings to be ignored not just in root
parent e599c777
/.settings
.settings
/log
/build.xml
/bin
/logref
\ No newline at end of file
/logref
......@@ -23,8 +23,8 @@ To use jCoAP core as a library in your projects, add the following dependency to
```xml
<dependency>
<groupId>org.ws4d.jcoap</groupId>
<artifactId>core</artifactId>
<version>1.1.1-SNAPSHOT</version>
<artifactId>jcoap-core</artifactId>
<version>1.1.2</version>
</dependency>
```
......@@ -32,8 +32,8 @@ To use jCoAP proxy as a library in your projects, add the following dependency t
```xml
<dependency>
<groupId>org.ws4d.jcoap</groupId>
<artifactId>proxy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>jcoap-proxy</artifactId>
<version>0.0.1</version>
</dependency>
```
......
......@@ -2,8 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.ws4d.jcoap</groupId>
<artifactId>proxy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>jcoap-proxy</artifactId>
<version>0.0.1</version>
<name>jCoAP Proxy</name>
<build>
<sourceDirectory>src</sourceDirectory>
......@@ -77,12 +77,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.1</version>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.ws4d.jcoap</groupId>
<artifactId>core</artifactId>
<version>1.1.1-SNAPSHOT</version>
<artifactId>jcoap-core</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
......
......@@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
......
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.ws4d.jcoap</groupId>
<artifactId>examples</artifactId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>jcoap-examples</artifactId>
<version>0.0.1</version>
<name>jCoAP Examples</name>
<description>Examples using jCoAP</description>
<build>
......@@ -22,12 +22,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.1</version>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.ws4d.jcoap</groupId>
<artifactId>core</artifactId>
<version>1.1.1-SNAPSHOT</version>
<artifactId>jcoap-core</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<url>https://gitlab.amd.e-technik.uni-rostock.de/ws4d/jcoap</url>
......
......@@ -178,7 +178,7 @@ public class Server {
while (true) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
} catch (@SuppressWarnings("unused") InterruptedException e) {
//nothing
}
temp.changed();
......
......@@ -44,7 +44,7 @@ public class CoapSampleResourceServer {
while(true){
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
} catch (@SuppressWarnings("unused") InterruptedException e) {
// do nothing
}
counter++;
......
......@@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="lib/jcoap-1.1.0-SNAPSHOT.jar" sourcepath="lib/jcoap-1.1.0-SNAPSHOT-sources.jar"/>
<classpathentry kind="lib" path="lib/jcoap-core-1.1.2.jar" sourcepath="lib/jcoap-core-1.1.2-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
......@@ -58,7 +58,7 @@ public class Client implements CoapClient {
// CoapRequest request = this.clientChannel.createRequest(reliable, requestCode);
/* FIXME 8: Set the resource path */
// request.setUriPath("/???");
// request.setUriPath(???);
/* TODO 13: Skip for now! In the 2nd step we add the observe option here
* Tip: the Parameter sequenceNumber is recommended to be 0
......
......@@ -2,8 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.ws4d.jcoap</groupId>
<artifactId>core</artifactId>
<version>1.1.1-SNAPSHOT</version>
<artifactId>jcoap-core</artifactId>
<version>1.1.2</version>
<name>jCoAP</name>
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
......
......@@ -114,10 +114,13 @@ public class BasicCoapSocketHandler implements CoapSocketHandler {
this.dgramSocket.setSoTimeout(0);
this.dgramSocket.setReceiveBufferSize(CoapConstants.RECEIVE_BUFFER_SIZE);
try{
this.dgramSocket.joinGroup(InetAddress.getByName(CoapConstants.COAP_ALL_NODES_IPV6_LL_MC_ADDR));
this.dgramSocket.joinGroup(InetAddress.getByName(CoapConstants.COAP_ALL_NODES_IPV6_SL_MC_ADDR));
this.dgramSocket.joinGroup(InetAddress.getByName(CoapConstants.COAP_ALL_NODES_IPV4_MC_ADDR));
} catch(Exception e1){
logger.warn("Multicast socket could not be opened. Continuing without Multicast support.");
}
this.workerThread = new WorkerThread();
this.workerThread.start();
......
......@@ -198,7 +198,7 @@ public class TimeoutHashMap<K, V> implements Map<K, V> {
// next delete in <time> milliseconds -> sleep
try {
Thread.sleep(time);
} catch (InterruptedException e) {
} catch (@SuppressWarnings("unused") InterruptedException e) {
// do nothing, InterruptedException is expected on a put
}
} else {
......@@ -206,7 +206,7 @@ public class TimeoutHashMap<K, V> implements Map<K, V> {
// we expect an interrupt when something is added
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException e) {
} catch (@SuppressWarnings("unused") InterruptedException e) {
// do nothing, InterruptedException is expected on a put
}
}
......
......@@ -71,8 +71,9 @@ public class PlugTest {
}
}
@SuppressWarnings("static-method") // adding static modifier breaks test
@Before
public static void setUp() {
public void setUp() {
// set up client
receivedResponse = null;
if (null == client) {
......@@ -99,8 +100,9 @@ public class PlugTest {
}
}
@SuppressWarnings("static-method") // adding static modifier breaks test
@After
public static void tearDown() {
public void tearDown() {
if (resourceServer != null) {
resourceServer.stop();
}
......@@ -133,8 +135,9 @@ public class PlugTest {
*/
//RELIABLE GET EXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void ReliableGet() throws InterruptedException{
public void ReliableGet() throws InterruptedException{
resourceServer.createResource(new BasicCoapResource("/resource", "content", CoapMediaType.text_plain));
CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.GET);
request.setUriPath("/resource");
......@@ -144,8 +147,9 @@ public class PlugTest {
}
//UNRELIABLE GET EXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void UnreliableGet() throws InterruptedException{
public void UnreliableGet() throws InterruptedException{
resourceServer.createResource(new BasicCoapResource("/resource", "content", CoapMediaType.text_plain));
CoapRequest request = clientChannel.createRequest(false, CoapRequestCode.GET);
request.setUriPath("/resource");
......@@ -155,8 +159,9 @@ public class PlugTest {
}
//RELIABLE PUT EXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void ReliablePut() throws InterruptedException{
public void ReliablePut() throws InterruptedException{
resourceServer.createResource(new BasicCoapResource("/resource", "content", CoapMediaType.text_plain));
CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.PUT);
request.setUriPath("/resource");
......@@ -167,8 +172,9 @@ public class PlugTest {
}
//UNRELIABLE PUT EXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void UnreliablePut() throws InterruptedException{
public void UnreliablePut() throws InterruptedException{
resourceServer.createResource(new BasicCoapResource("/resource", "content", CoapMediaType.text_plain));
CoapRequest request = clientChannel.createRequest(false, CoapRequestCode.PUT);
request.setUriPath("/resource");
......@@ -179,8 +185,9 @@ public class PlugTest {
}
//RELIABLE PUT NONEXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void ReliablePutNonExisting() throws InterruptedException{
public void ReliablePutNonExisting() throws InterruptedException{
resourceServer.allowRemoteResourceCreation(true);
CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.PUT);
request.setUriPath("/resource1");
......@@ -191,8 +198,9 @@ public class PlugTest {
}
//UNRELIABLE PUT NONEXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void UnreliablePutNonExisting() throws InterruptedException{
public void UnreliablePutNonExisting() throws InterruptedException{
resourceServer.allowRemoteResourceCreation(true);
CoapRequest request = clientChannel.createRequest(false, CoapRequestCode.PUT);
request.setUriPath("/resource2");
......@@ -203,8 +211,9 @@ public class PlugTest {
}
//RELIABLE PUT NONEXISTING NOT-ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void ReliablePutNonExistingCreationNotAllowed() throws InterruptedException{
public void ReliablePutNonExistingCreationNotAllowed() throws InterruptedException{
resourceServer.allowRemoteResourceCreation(false);
CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.PUT);
request.setUriPath("/resource3");
......@@ -215,8 +224,9 @@ public class PlugTest {
}
//UNRELIABLE PUT NONEXISTING NOT-ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void UnreliablePutNonExistingCreationNotAllowed() throws InterruptedException{
public void UnreliablePutNonExistingCreationNotAllowed() throws InterruptedException{
resourceServer.allowRemoteResourceCreation(false);
CoapRequest request = clientChannel.createRequest(false, CoapRequestCode.PUT);
request.setUriPath("/resource4");
......@@ -227,8 +237,9 @@ public class PlugTest {
}
// RELIABLE DELETE EXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void ReliableDelete() throws InterruptedException{
public void ReliableDelete() throws InterruptedException{
resourceServer.createResource(new BasicCoapResource("/resource", "content", CoapMediaType.text_plain));
CoapRequest request = clientChannel.createRequest(true, CoapRequestCode.DELETE);
request.setUriPath("/resource");
......@@ -239,8 +250,9 @@ public class PlugTest {
}
// UNRELIABLE DELETE EXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void UnreliableDelete() throws InterruptedException{
public void UnreliableDelete() throws InterruptedException{
resourceServer.createResource(new BasicCoapResource("/resource", "content", CoapMediaType.text_plain));
CoapRequest request = clientChannel.createRequest(false, CoapRequestCode.DELETE);
request.setUriPath("/resource");
......@@ -251,8 +263,9 @@ public class PlugTest {
}
// RELIABLE DELETE NONEXISTING ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void DeleteNonExisting() throws InterruptedException{
public void DeleteNonExisting() throws InterruptedException{
resourceServer.createResource(new BasicCoapResource("/resource", "content", CoapMediaType.text_plain));
CoapRequest request = clientChannel.createRequest(false, CoapRequestCode.DELETE);
request.setUriPath("/resource3");
......@@ -263,8 +276,9 @@ public class PlugTest {
}
// RELIABLE DELETE EXISTING NOT-ALLOWED
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void DeleteNotAllowed() throws InterruptedException{
public void DeleteNotAllowed() throws InterruptedException{
CoapResource res = new BasicCoapResource("/resource", "content", CoapMediaType.text_plain);
res.setDeletable(false);
resourceServer.createResource(res);
......@@ -281,9 +295,9 @@ public class PlugTest {
// RELIABLE GET PUT POST with separate Response -> 1 Test
// /.well-known/core
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void wellKnownFull() throws InterruptedException {
public void wellKnownFull() throws InterruptedException {
resourceServer.createResource(new BasicCoapResource("/resource1", "content1", CoapMediaType.text_plain)
.setResourceType("resource1Type")
.setInterfaceDescription("resource1Description"));
......@@ -298,8 +312,9 @@ public class PlugTest {
Encoder.ByteToString(receivedResponse.getPayload()));
}
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void wellKnownRT() throws InterruptedException {
public void wellKnownRT() throws InterruptedException {
resourceServer.createResource(new BasicCoapResource("/resource1", "content1", CoapMediaType.text_plain)
.setResourceType("resource1Type")
.setInterfaceDescription("resource1Description"));
......@@ -323,8 +338,9 @@ public class PlugTest {
// Path length
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test(expected = Exception.class)
public static void invalidNameTooLongResource() {
public void invalidNameTooLongResource() {
String resourcename = "";
for (int i = 0; i < 256; i++) {
resourcename += 'a';
......@@ -332,9 +348,10 @@ public class PlugTest {
CoapResource res = new BasicCoapResource("/" + resourcename, "", CoapMediaType.text_plain);
resourceServer.createResource(res);
}
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test(expected = IllegalArgumentException.class)
public static void invalidPathTooLongResource() {
public void invalidPathTooLongResource() {
String resourcename = "";
for (int i = 0; i < 256; i++) {
resourcename += 'a';
......@@ -350,22 +367,25 @@ public class PlugTest {
* ########################################################################
*/
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void validPathShortestResources() {
public void validPathShortestResources() {
// An empty path component is equivalent to an absolute path of "/"
CoapResource res = new BasicCoapResource("/test", "", CoapMediaType.text_plain);
resourceServer.createResource(res);
}
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void validPathRootResources() {
public void validPathRootResources() {
// An empty path component is equivalent to an absolute path of "/"
CoapResource res = new BasicCoapResource("", "", CoapMediaType.text_plain);
resourceServer.createResource(res);
}
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void validNameLongestResources() {
public void validNameLongestResources() {
String resourcename = "";
for (int i = 0; i < 255; i++) {
resourcename += 'a';
......@@ -374,8 +394,9 @@ public class PlugTest {
resourceServer.createResource(res);
}
@SuppressWarnings("static-method") // adding static modifier breaks test
@Test
public static void validPathLongestResources() {
public void validPathLongestResources() {
CoapResource res = new BasicCoapResource("/1/2/3/4/5", "", CoapMediaType.text_plain);
resourceServer.createResource(res);
}
......
......@@ -22,6 +22,7 @@ import org.ws4d.coap.core.tools.TimeoutHashMap;
*/
public class TimeoutHashMapTest {
@SuppressWarnings("unused") // to ignore unused exception
public static void main(String[] args) {
TimeoutHashMap<String, String> map = new TimeoutHashMap<String, String>(2000);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment