Skip to content
Snippets Groups Projects
Commit 91a6fc7a authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Do not include spring-security.xml in spring-main.xml

parent e0611583
Branches
Tags
No related merge requests found
Showing
with 46 additions and 38 deletions
......@@ -25,8 +25,6 @@
</property>
</bean>
<import resource="spring-security.xml" />
<context:component-scan base-package="de.thm.arsnova.dao,de.thm.arsnova.services,de.thm.arsnova.events" />
<context:annotation-config />
......
......@@ -7,7 +7,8 @@
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/spring-main.xml
</param-value>
/WEB-INF/spring/spring-security.xml
</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
......@@ -95,8 +96,5 @@
<session-config>
<tracking-mode>COOKIE</tracking-mode>
<!-- delete sessions after 6 hours -->
<session-timeout>360</session-timeout>
</session-config>
</web-app>
......@@ -23,6 +23,7 @@ import de.thm.arsnova.services.StubUserService;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml",
"file:src/test/resources/test-socketioconfig.xml"
})
......
......@@ -45,6 +45,7 @@ import de.thm.arsnova.services.StubUserService;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml",
"file:src/test/resources/test-socketioconfig.xml"
})
......
......@@ -23,6 +23,7 @@ import de.thm.arsnova.services.StubUserService;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml",
"file:src/test/resources/test-socketioconfig.xml"
})
......
......@@ -20,6 +20,7 @@ import org.springframework.web.context.WebApplicationContext;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml",
"file:src/test/resources/test-socketioconfig.xml"
})
......
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......@@ -39,6 +39,7 @@ import de.thm.arsnova.exceptions.NotFoundException;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml"
})
public class FeedbackServiceTest {
......@@ -48,14 +49,14 @@ public class FeedbackServiceTest {
@Autowired
StubUserService userService;
@Autowired
private StubDatabaseDao databaseDao;
@Before
public final void setup() {
userService.setUserAuthenticated(false);
feedbackService.saveFeedback("87654321", 0, new TestUser("testuser01"));
feedbackService.saveFeedback("87654321", 0, new TestUser("testuser02"));
feedbackService.saveFeedback("87654321", 1, new TestUser("testuser11"));
......@@ -73,8 +74,8 @@ public class FeedbackServiceTest {
feedbackService.saveFeedback("87654321", 3, new TestUser("testuser35"));
feedbackService.saveFeedback("87654321", 3, new TestUser("testuser36"));
feedbackService.saveFeedback("87654321", 3, new TestUser("testuser37"));
feedbackService.saveFeedback("18273645", 0, new TestUser("testuser01"));
feedbackService.saveFeedback("18273645", 0, new TestUser("testuser02"));
feedbackService.saveFeedback("18273645", 1, new TestUser("testuser11"));
......@@ -96,9 +97,9 @@ public class FeedbackServiceTest {
feedbackService.saveFeedback("18273645", 3, new TestUser("testuser39"));
feedbackService.saveFeedback("18273645", 3, new TestUser("testuser310"));
feedbackService.saveFeedback("18273645", 3, new TestUser("testuser311"));
}
@After
public final void cleanup() {
databaseDao.cleanupTestData();
......@@ -162,10 +163,10 @@ public class FeedbackServiceTest {
userService.setUserAuthenticated(true);
assertEquals(2.1904, feedbackService.getAverageFeedback("18273645"), 0.001);
}
public static class TestUser extends User {
private static final long serialVersionUID = 1L;
public TestUser(String username) {
super( new UsernamePasswordAuthenticationToken(username, "secret") );
}
......
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......@@ -18,7 +18,9 @@
*/
package de.thm.arsnova.services;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Test;
......@@ -36,6 +38,7 @@ import de.thm.arsnova.exceptions.UnauthorizedException;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml"
})
public class QuestionServiceTest {
......@@ -45,7 +48,7 @@ public class QuestionServiceTest {
@Autowired
StubUserService userService;
@Autowired
private StubDatabaseDao databaseDao;
......@@ -73,7 +76,7 @@ public class QuestionServiceTest {
userService.setUserAuthenticated(true);
assertEquals(1, questionService.getSkillQuestionCount("12345678"));
}
@Test
public void testShouldMarkInterposedQuestionAsReadIfSessionCreator() throws Exception {
userService.setUserAuthenticated(true);
......@@ -82,12 +85,12 @@ public class QuestionServiceTest {
theQ.set_id("the internal id");
theQ.setSessionId("12345678");
databaseDao.interposedQuestion = theQ;
questionService.readInterposedQuestion(theQ.get_id());
assertTrue(theQ.isRead());
}
@Test
public void testShouldNotMarkInterposedQuestionAsReadIfRegularUser() throws Exception {
userService.setUserAuthenticated(true, "regular user");
......@@ -96,9 +99,9 @@ public class QuestionServiceTest {
theQ.set_id("the internal id");
theQ.setSessionId("12345678");
databaseDao.interposedQuestion = theQ;
questionService.readInterposedQuestion(theQ.get_id());
assertFalse(theQ.isRead());
}
}
/*
* Copyright (C) 2012 THM webMedia
*
*
* This file is part of ARSnova.
*
* ARSnova is free software: you can redistribute it and/or modify
......@@ -21,11 +21,13 @@ package de.thm.arsnova.services;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import static org.mockito.Mockito.*;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -47,7 +49,8 @@ import de.thm.arsnova.exceptions.UnauthorizedException;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/test/resources/test-config.xml" })
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml" })
public class SessionServiceTest {
@Autowired
......@@ -55,7 +58,7 @@ public class SessionServiceTest {
@Autowired
private StubUserService userService;
@Autowired
private StubDatabaseDao databaseDao;
......@@ -64,7 +67,7 @@ public class SessionServiceTest {
databaseDao.cleanupTestData();
userService.setUserAuthenticated(false);
}
@Test
public void testShouldGenerateSessionKeyword() {
assertTrue(sessionService.generateKeyword().matches("^[0-9]{8}$"));
......@@ -118,19 +121,19 @@ public class SessionServiceTest {
IDatabaseDao tempDatabase = (IDatabaseDao) ReflectionTestUtils.getField(getTargetObject(sessionService), "databaseDao");
try {
userService.setUserAuthenticated(true);
Session session = new Session();
session.setCreator(userService.getCurrentUser().getUsername());
Question q1 = new Question();
Question q2 = new Question();
IDatabaseDao mockDatabase = mock(IDatabaseDao.class);
when(mockDatabase.getSkillQuestions(userService.getCurrentUser(), session)).thenReturn(Arrays.asList(q1, q2));
when(mockDatabase.getSession(anyString())).thenReturn(session);
ReflectionTestUtils.setField(getTargetObject(sessionService), "databaseDao", mockDatabase);
sessionService.deleteSession(session.getKeyword(), userService.getCurrentUser());
verify(mockDatabase).deleteQuestionWithAnswers(q1);
verify(mockDatabase).deleteQuestionWithAnswers(q2);
verify(mockDatabase).deleteSession(session);
......
......@@ -18,6 +18,7 @@ import de.thm.arsnova.entities.Statistics;
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",
"file:src/main/webapp/WEB-INF/spring/spring-main.xml",
"file:src/main/webapp/WEB-INF/spring/spring-security.xml",
"file:src/test/resources/test-config.xml"
})
public class StatisticsServiceTest {
......@@ -39,12 +40,12 @@ public class StatisticsServiceTest {
session.setActive(false);
databaseDao.saveSession(session);
}
@After
public final void cleanup() {
databaseDao.cleanupTestData();
}
@Test
public final void testShouldReturnNoActiveUsers() {
int actual = statisticsService.countActiveUsers();
......@@ -55,7 +56,7 @@ public class StatisticsServiceTest {
public final void testShouldReturnCurrentActiveUsers() {
Session session = new Session();
session.setKeyword("1278127812");
userService.setUserAuthenticated(true);
databaseDao.registerAsOnlineUser(userService.getCurrentUser(), session);
......@@ -63,7 +64,7 @@ public class StatisticsServiceTest {
assertEquals(1, actual);
userService.setUserAuthenticated(false);
}
@Test
public final void testShouldReturnStatistics() {
Statistics actual = statisticsService.getStatistics();
......
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