|
| 1 | +package de.rwth.idsg.steve; |
| 2 | + |
| 3 | +import de.rwth.idsg.steve.utils.StressTester; |
| 4 | +import de.rwth.idsg.steve.utils.__DatabasePreparer__; |
| 5 | +import lombok.extern.slf4j.Slf4j; |
| 6 | +import ocpp.cs._2015._10.AuthorizationStatus; |
| 7 | +import ocpp.cs._2015._10.AuthorizeRequest; |
| 8 | +import ocpp.cs._2015._10.AuthorizeResponse; |
| 9 | +import ocpp.cs._2015._10.BootNotificationRequest; |
| 10 | +import ocpp.cs._2015._10.BootNotificationResponse; |
| 11 | +import ocpp.cs._2015._10.CentralSystemService; |
| 12 | +import ocpp.cs._2015._10.RegistrationStatus; |
| 13 | +import org.junit.After; |
| 14 | +import org.junit.AfterClass; |
| 15 | +import org.junit.Assert; |
| 16 | +import org.junit.Before; |
| 17 | +import org.junit.BeforeClass; |
| 18 | +import org.junit.Test; |
| 19 | + |
| 20 | +import static de.rwth.idsg.steve.utils.Helpers.getForOcpp16; |
| 21 | +import static de.rwth.idsg.steve.utils.Helpers.getPath; |
| 22 | +import static de.rwth.idsg.steve.utils.Helpers.getRandomString; |
| 23 | + |
| 24 | +/** |
| 25 | + * @author Sevket Goekay <goekay@dbis.rwth-aachen.de> |
| 26 | + * @since 18.04.2018 |
| 27 | + */ |
| 28 | +@Slf4j |
| 29 | +public class StressTestSoapOCPP16 { |
| 30 | + |
| 31 | + private static final String REGISTERED_CHARGE_BOX_ID = __DatabasePreparer__.getRegisteredChargeBoxId(); |
| 32 | + |
| 33 | + private static final String path = getPath(); |
| 34 | + private static Application app; |
| 35 | + |
| 36 | + @BeforeClass |
| 37 | + public static void initClass() throws Exception { |
| 38 | + Assert.assertEquals(ApplicationProfile.TEST, SteveConfiguration.CONFIG.getProfile()); |
| 39 | + Assert.assertTrue(SteveConfiguration.CONFIG.getOcpp().isAutoRegisterUnknownStations()); |
| 40 | + |
| 41 | + app = new Application(); |
| 42 | + app.start(); |
| 43 | + } |
| 44 | + |
| 45 | + @AfterClass |
| 46 | + public static void destroyClass() throws Exception { |
| 47 | + if (app != null) { |
| 48 | + app.stop(); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + @Before |
| 53 | + public void init() { |
| 54 | + __DatabasePreparer__.prepare(); |
| 55 | + } |
| 56 | + |
| 57 | + @After |
| 58 | + public void destroy() { |
| 59 | + __DatabasePreparer__.cleanUp(); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + public void testBootNotification() throws Exception { |
| 64 | + StressTester tester = new StressTester(50, 5); |
| 65 | + |
| 66 | + CentralSystemService client = getForOcpp16(path); |
| 67 | + |
| 68 | + tester.test(() -> { |
| 69 | + BootNotificationResponse boot = client.bootNotification( |
| 70 | + new BootNotificationRequest() |
| 71 | + .withChargePointVendor(getRandomString()) |
| 72 | + .withChargePointModel(getRandomString()), |
| 73 | + getRandomString()); |
| 74 | + Assert.assertEquals(RegistrationStatus.ACCEPTED, boot.getStatus()); |
| 75 | + }); |
| 76 | + |
| 77 | + tester.shutDown(); |
| 78 | + } |
| 79 | + |
| 80 | + @Test |
| 81 | + public void testAuthorize() throws Exception { |
| 82 | + StressTester tester = new StressTester(100, 10); |
| 83 | + |
| 84 | + CentralSystemService client = getForOcpp16(path); |
| 85 | + |
| 86 | + tester.test(() -> { |
| 87 | + AuthorizeResponse auth = client.authorize( |
| 88 | + new AuthorizeRequest().withIdTag(getRandomString()), |
| 89 | + REGISTERED_CHARGE_BOX_ID); |
| 90 | + Assert.assertEquals(AuthorizationStatus.INVALID, auth.getIdTagInfo().getStatus()); |
| 91 | + }); |
| 92 | + |
| 93 | + tester.shutDown(); |
| 94 | + } |
| 95 | + |
| 96 | +} |
0 commit comments