Californium running the sandbox locally for integration tests - eclipse-californium/californium GitHub Wiki

Californium - running the sandbox locally for integration tests

Sometimes it's required to have access to more detailed logs in order to locate an fix interoperability issues.

One approach for that is to run the sandbox on your own PC

Requirements

Though Californium is implemented in java without own UI, you need a Java Runtime Environment, headless. The Java Development Kit will do it naturally as well and none headless also. The minimum required version is "1.7". in the meantime, I mainly use "java 11" and "java 17". The installation of that Java depends on your OS. Some came with an already installed java. Therefore first check, if it's already install executing

java -version

in a command-line-terminal. If it's already installed, the output will be similar to:

openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Ubuntu-0ubuntu120.04, mixed mode, sharing)

The variant and version may vary, but usually all from java "1.7" on will do it and all variants (jre or jdk, maybe headless) will work. If the command fails, you need to install it. How that is done, depends on your OS. For Ubuntu 20-04 LTS (or newer) try:

sudo apt install openjdk-17-jre-headless

Check the result again with java -version. If that's done, then copy your californium.jar to the host. If you want to run the cf-plugtest-server, it's the "/demo-apps/run/cf-plugtest-server-???.jar" (replace the ??? with the version your using, e.g. 3.11.0). The cf-plugtest-server-3.11.0.jar is also available for download.

Run it

Start the server by executing

java -jar cf-plugtest-server-3.11.0.jar

in a command-line-terminal in the folder, the cf-plugtest-server-3.11.0.jar was downloaded. The first start creates a logs-folder and a CaliforniumPlugtest3.properties, which may be edited, if a special configuration or feature should be tested.

If the common logging configuration provides already the information you need, your done.

Otherwise you may need to configure the logging as describe in Logs for Californium's demo-apps.

Create a "logback.xml" file using this template:

<configuration>

	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder 
			by default -->
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} %level [%logger{0}]: %msg%n</pattern>
		</encoder>
	</appender>

	<root level="DEBUG" >
		<appender-ref ref="STDOUT" />
	</root>

</configuration>

and start the server using:

java -Dlogback.configurationFile=./logback.xml -jar cf-plugtest-server-3.11.0.jar

That writes all DEBUG messages to the console. That may be too much now. So select, what you need. That requires some knowledge about the internal organization of Californium.

<configuration>

	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
		<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder 
			by default -->
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} %level [%logger{0}]: %msg%n</pattern>
		</encoder>
	</appender>

	<logger name="org.eclipse.californium.core" level="INFO" additivity="false">
		<appender-ref ref="STDOUT" />
	</logger>

	<logger name="org.eclipse.californium.scandium" level="DEBUG" additivity="false">
		<appender-ref ref="STDOUT" />
	</logger>

	<logger name="org.eclipse.californium.cose" level="INFO" additivity="false">
		<appender-ref ref="STDOUT" />
	</logger>

	<logger name="org.eclipse.californium.oscore" level="INFO" additivity="false">
		<appender-ref ref="STDOUT" />
	</logger>

	<root level="WARN" >
		<appender-ref ref="STDOUT" />
	</root>

</configuration>

This example enables more logging for the CoAP processing ("core"), and the OSCORE processing ("cose" and "oscore"). And much more for DTLS ("scandium").

For more information about the configuration file, you may check logback - configuration

⚠️ **GitHub.com Fallback** ⚠️