Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Timeus <[email protected]>
  • Loading branch information
nicolatimeus committed Jan 9, 2025
1 parent 3acc01b commit 861968f
Show file tree
Hide file tree
Showing 23 changed files with 87 additions and 888 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.equinox.launcher</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>log4j2-api-config</id>
<level>4</level>
Expand Down Expand Up @@ -288,10 +283,6 @@
<type>p2-installable-unit</type>
<artifactId>org.hamcrest.core</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.launcher</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.wireadmin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.equinox.launcher</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>log4j2-api-config</id>
<level>4</level>
Expand Down Expand Up @@ -292,10 +287,6 @@
<type>p2-installable-unit</type>
<artifactId>org.hamcrest.core</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.launcher</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.wireadmin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.equinox.launcher</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>log4j2-api-config</id>
<level>4</level>
Expand Down Expand Up @@ -292,10 +287,6 @@
<type>p2-installable-unit</type>
<artifactId>org.hamcrest.core</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.launcher</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.wireadmin</artifactId>
Expand Down
9 changes: 0 additions & 9 deletions kura/examples/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@
<type>p2-installable-unit</type>
<artifactId>org.hamcrest.core</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.eclipse.equinox.launcher</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>slf4j.api</artifactId>
Expand Down Expand Up @@ -330,11 +326,6 @@
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>org.eclipse.equinox.launcher</id>
<level>4</level>
<autoStart>true</autoStart>
</bundle>
<bundle>
<id>slf4j.api</id>
<level>4</level>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Import-Package: jakarta.servlet;version="5.0.0",
org.osgi.service.component;version="1.3.0",
org.osgi.service.event;version="1.4.0",
org.slf4j;version="1.7.21"
Require-Bundle: org.apache.felix.http.bridge;bundle-version="5.1.8"
1 change: 1 addition & 0 deletions kura/org.eclipse.kura.rest.provider/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ Import-Package: com.google.gson;version="2.9.0",
org.osgi.service.useradmin;version="1.1.0",
org.osgi.util.tracker;version="1.5.2",
org.slf4j;version="1.7.21"
Require-Bundle: org.eclipse.osgitech.rest.servlet.whiteboard;bundle-version="1.2.3"
Export-Package: org.eclipse.kura.rest.auth;version="1.0.0",
org.eclipse.kura.rest.utils;version="1.0.0"

This file was deleted.

6 changes: 2 additions & 4 deletions kura/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
-DbuildingWithTycho=true -Dosgi.locking=none
-Dds.showtrace=true
-Djava.io.tmpdir=/tmp
-Dorg.osgi.framework.storage=/tmp/osgi/framework_storage
-Dorg.osgi.framework.storage=${project.basedir}/osgi/framework_storage
-Dosgi.clean=true
-Dkura.home=${project.basedir}/target/kura
-Dkura.plugins=${project.basedir}/target/kura/plugins
Expand Down Expand Up @@ -240,7 +240,7 @@
-DbuildingWithTycho=true -Dosgi.locking=none
-Dds.showtrace=true
-Djava.io.tmpdir=/tmp
-Dorg.osgi.framework.storage=/tmp/osgi/framework_storage
-Dorg.osgi.framework.storage=${project.basedir}/osgi/framework_storage
-Dosgi.clean=true
-Dkura.home=${project.basedir}/target/kura
-Dkura.plugins=${project.basedir}/target/kura/plugins
Expand All @@ -251,11 +251,9 @@
-Dkura.configuration=file:${kura.basedir}/emulator/org.eclipse.kura.emulator/src/main/resources/kura.properties
-Dlog4j.configurationFile=file:${kura.basedir}/emulator/org.eclipse.kura.emulator/src/main/resources/log4j.xml
-Dorg.eclipse.kura.mode=emulator
-Dorg.eclipse.equinox.http.jetty.customizer.class=org.eclipse.kura.jetty.customizer.KuraJettyCustomizer
-Ddpa.configuration=/tmp/kura/dpa.properties
-Dosgi.console=5002
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
</tycho.surefire.testenv.args>
</properties>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
Expand All @@ -24,16 +23,12 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.kura.core.testutil.TestUtil;
import org.eclipse.kura.executor.Command;
import org.eclipse.kura.executor.CommandExecutorService;
import org.eclipse.kura.executor.CommandStatus;
import org.eclipse.kura.system.SystemService;
import org.eclipse.kura.test.annotation.TestTarget;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -306,69 +301,12 @@ public void getModelId() {
assertNotNull(systemService.getModelId());
}

@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void getModelName() throws NoSuchFieldException {
// remove the default value so that the command is run
Properties def = (Properties) TestUtil.getFieldValue(systemService.getProperties(), "defaults");
def.remove(SystemService.KEY_MODEL_NAME);

String modelName = systemService.getModelName();

assertNotNull(modelName);

String osName = systemService.getOsName();
if (!osName.contains("indows")) {
if (LINUX.equals(osName)) {
CommandStatus status = executorService.execute(new Command(new String[] { "dmidecode" }));
if (!status.getExitStatus().isSuccessful()) {
assertEquals(UNKNOWN, modelName);
}

// note: this assert works locally and on travis, but not on hudson
// assertNotEquals("UNKNOWN", modelName);

assertNotEquals("DevModelName", modelName);
}
} else {
assertEquals(UNKNOWN, modelName);
}
}

@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void getPartNumber() {
assertNotNull(systemService.getPartNumber());
}

@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void getSerialNumber() throws NoSuchFieldException {
// remove the default value so that the command is run
Properties def = (Properties) TestUtil.getFieldValue(systemService.getProperties(), "defaults");
def.remove(SystemService.KEY_SERIAL_NUM);

String serialNumber = systemService.getSerialNumber();

assertNotNull(serialNumber);

String osName = systemService.getOsName();
if (!osName.contains("indows")) {
if (LINUX.equals(osName)) {
CommandStatus status = executorService.execute(new Command(new String[] { "dmidecode" }));
if (!status.getExitStatus().isSuccessful()) {
assertEquals(UNKNOWN, serialNumber);
}
// note: this assert works locally and on travis, but not on hudson
// assertNotEquals("UNKNOWN", serialNumber);

assertNotEquals("DevSerialNumber", serialNumber);
}
} else {
assertEquals(UNKNOWN, serialNumber);
}
}

@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void shouldGetDefaultLogManagerProperty() {
Expand Down
10 changes: 5 additions & 5 deletions kura/test/org.eclipse.kura.core.testutil/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Bundle-Version: 6.0.0.qualifier
Bundle-Vendor: Eclipse Kura
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Import-Package: com.eclipsesource.json;version="0.9.5",
jakarta.servlet;version="[6.0.0,7.0.0)",
jakarta.servlet.http;version="[6.0.0,7.0.0)",
javax.servlet;version="3.1.0",
javax.servlet.http;version="3.1.0",
junit.framework;version="[4.12.0,5.0.0)",
Expand All @@ -22,11 +24,9 @@ Import-Package: com.eclipsesource.json;version="0.9.5",
org.bouncycastle.operator;version="1.78.1",
org.bouncycastle.operator.jcajce;version="1.78.1",
org.bouncycastle.x509.extension;version="1.78.1",
org.eclipse.jetty.server;version="9.4.41",
org.eclipse.jetty.server.handler;version="9.4.41",
org.eclipse.jetty.servlet;version="9.4.41",
org.eclipse.jetty.util;version="9.4.41",
org.eclipse.jetty.util.component;version="9.4.41",
org.eclipse.jetty.ee10.servlet;version="[12.0.0,13.0.0)",
org.eclipse.jetty.server;version="[12.0.0,13.0.0)",
org.eclipse.jetty.util;version="[12.0.0,13.0.0)",
org.eclipse.kura;version="[1.6,2.0)",
org.eclipse.kura.configuration;version="[1.2,2.0)",
org.eclipse.kura.core.data.util;version="[1.0,2.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
import java.util.Optional;
import java.util.function.Consumer;

import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
import org.eclipse.jetty.ee10.servlet.ServletHolder;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

public class TestServer implements Closeable {

private final Server server;
Expand Down
Loading

0 comments on commit 861968f

Please sign in to comment.