Update the toolkits for Java quick test during OA and code checking
This commit is contained in:
parent
080fd2df6d
commit
bc597e93c2
@ -16,23 +16,18 @@
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!-- UTILS -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.10.10</version>
|
||||
<version>${joda-time.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>javax.persistence-api</artifactId>
|
||||
|
@ -1,97 +1,97 @@
|
||||
package com.ossez.codebank.algorithm;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Main Test Class
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*/
|
||||
public class Main {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Main.class);
|
||||
|
||||
private static Options options = new Options();
|
||||
private static Properties properties = new Properties();
|
||||
|
||||
private static CommandLine cl = null;
|
||||
|
||||
private static boolean dryRun = false;
|
||||
private static int limit = 0;
|
||||
private static boolean force = false;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// get the idx feed properties file
|
||||
Main.parseProperties();
|
||||
|
||||
// load console options
|
||||
Main.parseCommandLine(args);
|
||||
|
||||
logger.debug("Starting feeds...");
|
||||
System.out.println("starting feeds...");
|
||||
|
||||
// execute the feeds
|
||||
Main.executeFeeds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the feeds specified in the feeds.properties file.
|
||||
*/
|
||||
private static void executeFeeds() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the properties file to get a list of all feeds.
|
||||
*/
|
||||
private static void parseProperties() {
|
||||
try {
|
||||
// load the properties file
|
||||
logger.debug("Parsing properties");
|
||||
Main.properties.load(Main.class.getClassLoader().getResourceAsStream("rets.properties"));
|
||||
|
||||
// load the feeds
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Could not parse feed properties", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles creation of console options.
|
||||
*/
|
||||
private static void parseCommandLine(String[] args) {
|
||||
|
||||
// parse command line options
|
||||
CommandLineParser parser = new GnuParser();
|
||||
|
||||
try {
|
||||
Main.cl = parser.parse(Main.options, args);
|
||||
|
||||
// get the dry run option
|
||||
Main.dryRun = Main.cl.hasOption("d");
|
||||
logger.trace("Value of dryRun: " + dryRun);
|
||||
|
||||
// get the limit option
|
||||
// Main.limit = Utility.parseInt(Main.cl.getOptionValue("l", "0"));
|
||||
logger.trace("Value of limit: " + Main.limit);
|
||||
|
||||
// get the force option
|
||||
Main.force = Main.cl.hasOption("u");
|
||||
logger.trace("Value of force: " + Main.force);
|
||||
} catch (Exception ex) {
|
||||
logger.error("An error ocurred parsing command line arguments", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.ossez.toolkits.codebank;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Main Test Class
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*/
|
||||
public class Main {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Main.class);
|
||||
|
||||
private static Options options = new Options();
|
||||
private static Properties properties = new Properties();
|
||||
|
||||
private static CommandLine cl = null;
|
||||
|
||||
private static boolean dryRun = false;
|
||||
private static int limit = 0;
|
||||
private static boolean force = false;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// get the idx feed properties file
|
||||
Main.parseProperties();
|
||||
|
||||
// load console options
|
||||
Main.parseCommandLine(args);
|
||||
|
||||
logger.debug("Starting feeds...");
|
||||
System.out.println("starting feeds...");
|
||||
|
||||
// execute the feeds
|
||||
Main.executeFeeds();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the feeds specified in the feeds.properties file.
|
||||
*/
|
||||
private static void executeFeeds() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the properties file to get a list of all feeds.
|
||||
*/
|
||||
private static void parseProperties() {
|
||||
try {
|
||||
// load the properties file
|
||||
logger.debug("Parsing properties");
|
||||
Main.properties.load(Main.class.getClassLoader().getResourceAsStream("rets.properties"));
|
||||
|
||||
// load the feeds
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
logger.error("Could not parse feed properties", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles creation of console options.
|
||||
*/
|
||||
private static void parseCommandLine(String[] args) {
|
||||
|
||||
// parse command line options
|
||||
CommandLineParser parser = new GnuParser();
|
||||
|
||||
try {
|
||||
Main.cl = parser.parse(Main.options, args);
|
||||
|
||||
// get the dry run option
|
||||
Main.dryRun = Main.cl.hasOption("d");
|
||||
logger.trace("Value of dryRun: " + dryRun);
|
||||
|
||||
// get the limit option
|
||||
// Main.limit = Utility.parseInt(Main.cl.getOptionValue("l", "0"));
|
||||
logger.trace("Value of limit: " + Main.limit);
|
||||
|
||||
// get the force option
|
||||
Main.force = Main.cl.hasOption("u");
|
||||
logger.trace("Value of force: " + Main.force);
|
||||
} catch (Exception ex) {
|
||||
logger.error("An error ocurred parsing command line arguments", ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,18 @@
|
||||
package com.ossez.codebank.algorithm.objplusclass;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author YuCheng
|
||||
*
|
||||
*/
|
||||
public class CreateObject {
|
||||
public CreateObject(String name) {
|
||||
// This constructor has one parameter, name
|
||||
System.out.println("小狗的名字是: " + name);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Following statement would create an object myPuppy
|
||||
CreateObject myPuppy = new CreateObject("Tomcat");
|
||||
}
|
||||
}
|
||||
package com.ossez.toolkits.codebank.algorithm.objplusclass;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author YuCheng
|
||||
*
|
||||
*/
|
||||
public class CreateObject {
|
||||
public CreateObject(String name) {
|
||||
// This constructor has one parameter, name
|
||||
System.out.println("小狗的名字是: " + name);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Following statement would create an object myPuppy
|
||||
CreateObject myPuppy = new CreateObject("Tomcat");
|
||||
}
|
||||
}
|
@ -1,22 +1,22 @@
|
||||
package com.ossez.codebank.algorithm.overview;
|
||||
|
||||
/**
|
||||
* Java Tutorial
|
||||
*
|
||||
* @author YuCheng
|
||||
*
|
||||
*/
|
||||
class FreshJuice {
|
||||
enum FreshJuiceSize {
|
||||
SMALL, MEDIUM, LARGE
|
||||
}
|
||||
|
||||
FreshJuiceSize size;
|
||||
}
|
||||
|
||||
public class FreshJuiceEnums {
|
||||
public static void main(String[] args) {
|
||||
FreshJuice juice = new FreshJuice();
|
||||
juice.size = FreshJuice.FreshJuiceSize.MEDIUM;
|
||||
}
|
||||
package com.ossez.toolkits.codebank.algorithm.overview;
|
||||
|
||||
/**
|
||||
* Java Tutorial
|
||||
*
|
||||
* @author YuCheng
|
||||
*
|
||||
*/
|
||||
class FreshJuice {
|
||||
enum FreshJuiceSize {
|
||||
SMALL, MEDIUM, LARGE
|
||||
}
|
||||
|
||||
FreshJuiceSize size;
|
||||
}
|
||||
|
||||
public class FreshJuiceEnums {
|
||||
public static void main(String[] args) {
|
||||
FreshJuice juice = new FreshJuice();
|
||||
juice.size = FreshJuice.FreshJuiceSize.MEDIUM;
|
||||
}
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
package com.ossez.codebank.algorithm.overview;
|
||||
|
||||
/**
|
||||
* Java Tutorial
|
||||
*
|
||||
* This is my first java program. This will print 'Hello World' as the output This is an example of multi-line comments
|
||||
*
|
||||
* @author YuCheng
|
||||
*
|
||||
*/
|
||||
public class HelloWorld {
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
}
|
||||
package com.ossez.toolkits.codebank.algorithm.overview;
|
||||
|
||||
/**
|
||||
* Java Tutorial
|
||||
*
|
||||
* This is my first java program. This will print 'Hello World' as the output This is an example of multi-line comments
|
||||
*
|
||||
* @author YuCheng
|
||||
*
|
||||
*/
|
||||
public class HelloWorld {
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.ossez.toolkits.codebank.tests;
|
||||
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author YuCheng
|
||||
*
|
||||
*/
|
||||
public class BitOperationTest {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(BitOperationTest.class);
|
||||
|
||||
/**
|
||||
* 35 https://www.lintcode.com/problem/reverse-linked-list/description
|
||||
*/
|
||||
@Test
|
||||
public void testInt2Bit() {
|
||||
logger.debug("BEGIN");
|
||||
System.out.println(Integer.toBinaryString(5));
|
||||
System.out.println(Integer.toBinaryString(2));
|
||||
|
||||
System.out.println(Integer.toBinaryString(2 << 2));
|
||||
|
||||
System.out.println(Integer.parseInt(Integer.toBinaryString(2 << 2), 2));
|
||||
|
||||
System.out.println(5 / 3);
|
||||
System.out.println(5 % 3);
|
||||
FastMath.pow(2, 3);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.ossez.toolkits.codebank.tests;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
/**
|
||||
* @author YuCheng
|
||||
*/
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
@Slf4j
|
||||
public class EmptyQuickTest {
|
||||
|
||||
@BeforeEach
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
protected void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMain() {
|
||||
|
||||
log.info("TEST MAIN - BEGIN");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.ossez.codebank.algorithm.tests;
|
||||
package com.ossez.toolkits.codebank.tests.algorithm;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
@ -1,4 +1,4 @@
|
||||
package com.ossez.codebank.algorithm.tests;
|
||||
package com.ossez.toolkits.codebank.tests.algorithm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
@ -1,9 +1,6 @@
|
||||
package com.ossez.toolkits.codebank.tests;
|
||||
package com.ossez.toolkits.codebank.tests.interview;
|
||||
|
||||
import com.google.api.gbase.client.NumberUnit;
|
||||
import com.ibm.icu.impl.CharTrie;
|
||||
import com.ossez.toolkits.codebank.common.model.request.TopicRequest;
|
||||
import org.apache.commons.lang3.CharUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
Loading…
x
Reference in New Issue
Block a user