Skip to content
Merged
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
13 changes: 4 additions & 9 deletions src/test/java/edu/kit/scc/dem/wapsrv/app/FusekiRunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @version 1.1
*/
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {FusekiRunner.class, JenaDataBase.class, WapServerConfigMock.class})
@SpringBootTest(classes = {FusekiRunner.class, JenaDataBase.class, WapServerConfigSpy.class})
@ActiveProfiles("test")
class FusekiRunnerTest {
@Autowired
Expand Down Expand Up @@ -72,24 +72,19 @@ final void testInit() {
when(wapServerConfig.getSparqlReadIp()).thenReturn("localhost");
when(wapServerConfig.getSparqlWriteIp()).thenReturn("localhost");
// test readPort > 0 || writePort > 0
// test true || false
when(wapServerConfig.getSparqlReadPort()).thenReturn(3330);
// test with disabled write port
when(wapServerConfig.getSparqlWritePort()).thenReturn(-1);
objFusekiRunner.init();
objFusekiRunner.deinit();
// test false || true
// test with disabled read port
when(wapServerConfig.getSparqlReadPort()).thenReturn(-1);
when(wapServerConfig.getSparqlWritePort()).thenReturn(3331);
objFusekiRunner.init();
objFusekiRunner.deinit();
// test false || false
// test with disabled read and write port
when(wapServerConfig.getSparqlReadPort()).thenReturn(-1);
when(wapServerConfig.getSparqlWritePort()).thenReturn(-1);
objFusekiRunner.init();
objFusekiRunner.deinit();
// set back to default
when(wapServerConfig.getSparqlReadPort()).thenReturn(3330);
when(wapServerConfig.getSparqlWritePort()).thenReturn(3331);
}

/**
Expand Down
40 changes: 0 additions & 40 deletions src/test/java/edu/kit/scc/dem/wapsrv/app/WapServerConfigMock.java

This file was deleted.

31 changes: 31 additions & 0 deletions src/test/java/edu/kit/scc/dem/wapsrv/app/WapServerConfigSpy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package edu.kit.scc.dem.wapsrv.app;

import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;

/**
* @author Matthias Dressel
* @author Michael Hitzker
* @author Markus Hoefler
* @author Andreas Loeffler
* @author Timo Schmidt
* @version 1.1
*/
@Configuration
@Profile("test")
public class WapServerConfigSpy {
/**
* Providing a fake WapServerConfig for testing. Separate class to work with spring @autowired.
*
* @return WapServerConfig spy
*/
@Bean
@Primary
public WapServerConfig wapServerConfig() {
WapServerConfig real = new WapServerConfig();
return Mockito.spy(real);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import edu.kit.scc.dem.wapsrv.app.EtagFactory;
import edu.kit.scc.dem.wapsrv.app.EtagFactoryMock;
import edu.kit.scc.dem.wapsrv.app.WapServerConfig;
import edu.kit.scc.dem.wapsrv.app.WapServerConfigMock;
import edu.kit.scc.dem.wapsrv.app.WapServerConfigSpy;
import edu.kit.scc.dem.wapsrv.model.Container;
import edu.kit.scc.dem.wapsrv.model.ModelFactory;
import edu.kit.scc.dem.wapsrv.model.Page;
Expand All @@ -38,7 +38,6 @@
import edu.kit.scc.dem.wapsrv.model.validators.ValidatorRegistry;
import edu.kit.scc.dem.wapsrv.repository.CollectedRepository;
import edu.kit.scc.dem.wapsrv.repository.RepositoryMock;
import edu.kit.scc.dem.wapsrv.repository.jena.JenaRepository;
import edu.kit.scc.dem.wapsrv.testscommon.ModelFactoryMock;
import org.springframework.context.annotation.ComponentScan;

Expand All @@ -55,7 +54,7 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {ContainerServiceImpl.class, RepositoryMock.class, ModelFactoryMock.class,
EtagFactoryMock.class, JsonLdProfileRegistry.class, ValidatorRegistry.class, WapServerConfigMock.class,
EtagFactoryMock.class, JsonLdProfileRegistry.class, ValidatorRegistry.class, WapServerConfigSpy.class,
JsonLdValidator.class, Validator.class})
@ExtendWith(HoverflyExtension.class)
@HoverflySimulate(source = @HoverflySimulate.Source(value = "w3c_simulation.json", type = HoverflySimulate.SourceType.DEFAULT_PATH))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import edu.kit.scc.dem.wapsrv.app.EtagFactory;
import edu.kit.scc.dem.wapsrv.app.EtagFactoryMock;
import edu.kit.scc.dem.wapsrv.app.WapServerConfig;
import edu.kit.scc.dem.wapsrv.app.WapServerConfigMock;
import edu.kit.scc.dem.wapsrv.app.WapServerConfigSpy;
import edu.kit.scc.dem.wapsrv.exceptions.ContainerNotEmptyException;
import edu.kit.scc.dem.wapsrv.exceptions.InvalidContainerException;
import edu.kit.scc.dem.wapsrv.exceptions.ResourceDeletedException;
Expand Down Expand Up @@ -66,7 +66,7 @@
// @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {ContainerServiceImpl.class, RepositoryMock.class, ModelFactoryMock.class,
EtagFactoryMock.class, JsonLdProfileRegistry.class, ValidatorRegistry.class, WapServerConfigMock.class,
EtagFactoryMock.class, JsonLdProfileRegistry.class, ValidatorRegistry.class, WapServerConfigSpy.class,
JsonLdValidator.class, Validator.class})
@ExtendWith(HoverflyExtension.class)
@HoverflySimulate(source = @HoverflySimulate.Source(value = "w3c_simulation.json", type = HoverflySimulate.SourceType.DEFAULT_PATH))
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/test-config/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WebClientFolder=webcontent
JsonLdProfileFolder=profiles
SparqlReadIp=*
EnableContentNegotiation=true
SparqlReadPort=4330
SparqlReadPort=44330
Hostname=localhost
WapIp=localhost
EnableMandatoryLabelInContainers=false
Expand All @@ -18,7 +18,7 @@ EnableHttps=false
JsonLdFrameFolder=./profiles
JsonLdValidator_SchemaFolder=./schemas
SimpleFormatters=NTRIPLES*application/n-triples|RDF_JSON*application/rdf+json
SparqlWritePort=4331
SparqlWritePort=44331
SparqlWriteIp=localhost
PageSize=20
MultipleAnnotationPost=true
Expand Down
Loading