Skip to content

Commit

Permalink
added boolean type to StartupParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Timoshenko committed Jul 30, 2019
1 parent f87b1e2 commit 7e232b1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private StartupParameter getValue(Method aMethod, AStartupParameter aAnnotation)
Object value;
if(type == int.class) {
value = Integer.parseInt(textValue);
} else if (type == boolean.class) {
value = Boolean.parseBoolean(textValue);
} else if(type == String.class) {
value = textValue;
} else if(type == File.class) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.payneteasy.startup.parameters;

import java.io.File;

public interface IStartupConfig {

@AStartupParameter(name = "WEB_SERVER_PORT", value = "8080")
int webServerPort();

@AStartupParameter(name = "WEB_SERVER_CONTEXT", value = "/")
String webServerContext();

@AStartupParameter(name = "UPLOAD_DIR", value = "./uploadDir")
File getUploadDir();

@AStartupParameter(name = "USE_DEBUG_MODE", value = "true")
boolean useDebugMode();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.payneteasy.startup.parameters;

import org.junit.Test;

import java.io.File;

import static org.junit.Assert.*;

public class StartupParametersFactoryTest {

@Test
public void getStartupParametersTest() {
IStartupConfig startupConfig = StartupParametersFactory.getStartupParameters(IStartupConfig.class);

File file = startupConfig.getUploadDir();
assertEquals("./uploadDir", file.getPath());

int port = startupConfig.webServerPort();
assertEquals(8080, port);

String webServerContext = startupConfig.webServerContext();
assertEquals("/", webServerContext);

boolean useDebugMode = startupConfig.useDebugMode();
assertTrue(useDebugMode);
}
}

0 comments on commit 7e232b1

Please sign in to comment.