Skip to content

Commit

Permalink
Merge pull request #2 from atdev/at_add_boolean_type
Browse files Browse the repository at this point in the history
Added boolean type to Startup Parameters
  • Loading branch information
evsinev authored Jul 30, 2019
2 parents f87b1e2 + 7e232b1 commit 3d78149
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 3d78149

Please sign in to comment.