├── .gitignore ├── atup-case ├── mvn-eclipse.bat ├── mvn-eclipse.sh ├── pom.xml ├── readme.md └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── feuyeux │ │ │ └── jaxrs2 │ │ │ └── atup │ │ │ └── cases │ │ │ ├── AtupTestCaseApplication.java │ │ │ ├── resource │ │ │ ├── AtupTestCaseResource.java │ │ │ ├── AtupTestJobResource.java │ │ │ ├── AtupTestResultResource.java │ │ │ └── AtupTestSuiteResource.java │ │ │ ├── runner │ │ │ └── LaunchTestRunner.java │ │ │ └── service │ │ │ ├── AtupTestCaseService.java │ │ │ ├── AtupTestResultService.java │ │ │ ├── AtupTestSuiteService.java │ │ │ └── JobLaunchService.java │ ├── resources │ │ ├── META-INF │ │ │ └── persistence.xml │ │ ├── applicationContext.xml │ │ ├── applicationContext2.xml │ │ └── log4j2.xml │ └── webapp │ │ └── WEB-INF │ │ └── web.xml │ └── test │ └── java │ └── org │ └── feuyeux │ └── jaxrs2 │ └── atup │ └── cases │ ├── ConcurrentTaskTest.java │ ├── dao │ ├── TUTestCaseDao.java │ ├── TUTestResultDao.java │ └── TUTestSuiteDao.java │ ├── resource │ ├── TITestCaseResource.java │ ├── TITestResultResource.java │ └── TITestSuiteResource.java │ └── service │ └── TUJobQueue.java ├── atup-core ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── feuyeux │ └── jaxrs2 │ └── atup │ └── core │ ├── constant │ ├── AtupApi.java │ ├── AtupParam.java │ └── AtupVariable.java │ ├── dao │ ├── AtupDao.java │ ├── AtupDeviceDao.java │ ├── AtupTestCaseDao.java │ ├── AtupTestResultDao.java │ ├── AtupTestSuiteDao.java │ └── AtupUserDao.java │ ├── domain │ ├── AtupDevice.java │ ├── AtupTestCase.java │ ├── AtupTestResult.java │ ├── AtupTestSuite.java │ └── AtupUser.java │ ├── fake │ ├── CreatTestSuite.java │ ├── CreateDevice.java │ ├── CreateTestCase.java │ ├── CreateTestResult.java │ └── CreateUser.java │ ├── info │ ├── AtupDeviceListInfo.java │ ├── AtupErrorCode.java │ ├── AtupErrorInfo.java │ ├── AtupInfo.java │ ├── AtupTestCaseListInfo.java │ ├── AtupTestJobInfo.java │ ├── AtupTestJobListInfo.java │ ├── AtupTestResultListInfo.java │ ├── AtupTestSuiteInfo.java │ ├── AtupTestSuiteListInfo.java │ ├── AtupUserInfo.java │ └── AtupUserListInfo.java │ ├── rest │ ├── AtupRequest.java │ └── AtupRequestParam.java │ └── util │ ├── AtupCrossDomainFilter.java │ └── JaxbDateSerializer.java ├── atup-device ├── mvn-eclipse.bat ├── mvn-eclipse.sh ├── pom.xml ├── readme.md └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── feuyeux │ │ │ └── jaxrs2 │ │ │ └── atup │ │ │ └── device │ │ │ ├── AtupDeviceApplication.java │ │ │ ├── resource │ │ │ └── AtupDeviceResource.java │ │ │ └── service │ │ │ ├── AtupDeviceService.java │ │ │ └── StationDetectService.java │ ├── resources │ │ ├── META-INF │ │ │ └── persistence.xml │ │ ├── applicationContext.xml │ │ ├── applicationContext2.xml │ │ └── log4j2.xml │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.jsp │ └── test │ └── java │ └── org │ └── feuyeux │ └── jaxrs2 │ └── atup │ └── device │ ├── dao │ └── TUDeviceDao.java │ └── resource │ └── TSDeviceResource.java ├── atup-page ├── mvn-eclipse.bat ├── mvn-eclipse.sh ├── pom.xml └── src │ └── main │ └── webapp │ ├── cases │ ├── testCase.html │ ├── testCases.html │ ├── testResult.html │ ├── testResults.html │ ├── testSuite.html │ └── testSuites.html │ ├── devices │ ├── device.html │ └── devices.html │ ├── favicon.ico │ ├── index.html │ ├── jobs │ ├── jobsQueue.html │ └── runningJobs.html │ ├── js │ ├── atupCommon_staging.js │ ├── atupRest.js │ ├── cases │ │ ├── testCase.js │ │ ├── testCases.js │ │ ├── testSuite.js │ │ └── testSuites.js │ ├── devices │ │ ├── device.js │ │ └── devices.js │ ├── index_buildtime.js │ ├── jobs │ │ ├── testJob.js │ │ └── testJobs.js │ ├── md5.js │ ├── results │ │ ├── testResult.js │ │ └── testResults.js │ └── users │ │ ├── user.js │ │ └── users.js │ ├── signIn.html │ ├── signUp.html │ ├── storageTest.html │ ├── users │ ├── user.html │ └── users.html │ └── webjars │ ├── jquery │ └── 2.0.3 │ │ ├── jquery.js │ │ └── jquery.min.js │ └── readme.txt ├── atup-test-station ├── mvn-eclipse.bat ├── mvn-eclipse.sh ├── pom.xml ├── readme.md └── src │ ├── main │ ├── WEB-INF │ │ └── web.xml │ ├── java │ │ └── org │ │ │ └── feuyeux │ │ │ └── jaxrs2 │ │ │ └── atup │ │ │ └── station │ │ │ ├── TestStationApplication.java │ │ │ └── resource │ │ │ └── AtupStationResource.java │ └── resources │ │ ├── META-INF │ │ └── persistence.xml │ │ ├── applicationContext.xml │ │ ├── applicationContext0.xml │ │ └── log4j2.xml │ └── test │ └── java │ └── org │ └── feuyeux │ └── jaxrs2 │ └── atup │ └── station │ └── resource │ └── TIAtupStationResource.java ├── atup-topology.png ├── atup-user ├── mvn-eclipse.bat ├── mvn-eclipse.sh ├── pom.xml ├── readme.md └── src │ ├── main │ ├── WEB-INF │ │ └── web.xml │ ├── java │ │ └── org │ │ │ └── feuyeux │ │ │ └── jaxrs2 │ │ │ └── atup │ │ │ └── user │ │ │ ├── AtupUserApplication.java │ │ │ ├── resource │ │ │ └── AtupUserResource.java │ │ │ └── service │ │ │ └── AtupUserService.java │ └── resources │ │ ├── META-INF │ │ └── persistence.xml │ │ ├── applicationContext.xml │ │ ├── applicationContext2.xml │ │ ├── log4j2.xml │ │ └── section │ │ └── staging.properties │ └── test │ └── java │ └── org │ └── feuyeux │ └── jaxrs2 │ └── atup │ └── user │ ├── dao │ └── TUAtupUserDao.java │ └── resource │ └── TIAtupUserResource.java ├── document ├── atup-ddl │ ├── atup-case.sql │ ├── atup-device.sql │ ├── atup-result.sql │ ├── atup-suite.sql │ └── atup-user.sql ├── curl-script │ ├── detect-devices.sh │ └── launch-jobs.sh ├── job_flow_test_log.txt └── nginx │ └── nginx_cross_domain.txt ├── mvn-eclipse-all.bat ├── mvn-eclipse-all.sh ├── pom.xml └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.jar 3 | *.war 4 | *.ear 5 | .settings 6 | target 7 | work 8 | .DS_Store 9 | .classpath 10 | .project 11 | .db 12 | .idea 13 | *.iml 14 | nb-configuration.xml 15 | Thumbs.db 16 | *.xml~ 17 | *.log 18 | *.sh~ 19 | -------------------------------------------------------------------------------- /atup-case/mvn-eclipse.bat: -------------------------------------------------------------------------------- 1 | cd %1 2 | call mvn eclipse:clean && mvn -Dwtp.version=3.5.1 eclipse:eclipse -------------------------------------------------------------------------------- /atup-case/mvn-eclipse.sh: -------------------------------------------------------------------------------- 1 | cd $1 2 | mvn -Dwtp.version=3.5.1 eclipse:clean eclipse:eclipse 3 | mvn clean install -Dmaven.test.skip=true 4 | mvn dependency:sources 5 | -------------------------------------------------------------------------------- /atup-case/readme.md: -------------------------------------------------------------------------------- 1 | Test Suite Type: 2 | NORMAL_SUITE = 1; 3 | PERFORMANCE_SUITE = 2; 4 | EDGE_SUITE = 3; 5 | 6 | Test Job Priority: 7 | HIGH = 0; 8 | MEDIUM = 1; 9 | LOW = 2; -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/AtupTestCaseApplication.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases; 2 | 3 | import org.feuyeux.jaxrs2.atup.cases.resource.AtupTestCaseResource; 4 | import org.feuyeux.jaxrs2.atup.cases.resource.AtupTestJobResource; 5 | import org.feuyeux.jaxrs2.atup.cases.resource.AtupTestResultResource; 6 | import org.feuyeux.jaxrs2.atup.cases.resource.AtupTestSuiteResource; 7 | import org.glassfish.jersey.server.ResourceConfig; 8 | 9 | import javax.ws.rs.ApplicationPath; 10 | 11 | @ApplicationPath("/rest-api/*") 12 | class AtupTestCaseApplication extends ResourceConfig { 13 | public AtupTestCaseApplication() { 14 | register(AtupTestSuiteResource.class); 15 | register(AtupTestCaseResource.class); 16 | register(AtupTestResultResource.class); 17 | register(AtupTestJobResource.class); 18 | register(org.feuyeux.jaxrs2.atup.core.util.AtupCrossDomainFilter.class); 19 | } 20 | } -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/resource/AtupTestCaseResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.cases.service.AtupTestCaseService; 4 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 6 | import org.feuyeux.jaxrs2.atup.core.info.AtupErrorCode; 7 | import org.feuyeux.jaxrs2.atup.core.info.AtupErrorInfo; 8 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestCaseListInfo; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import javax.ws.rs.*; 13 | import javax.ws.rs.core.MediaType; 14 | 15 | @Component 16 | @Path(AtupApi.TEST_CASE_PATH) 17 | public class AtupTestCaseResource { 18 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(AtupTestCaseResource.class.getName()); 19 | @Autowired 20 | AtupTestCaseService service; 21 | 22 | public AtupTestCaseResource() { 23 | 24 | } 25 | 26 | @GET 27 | @Path("cases") 28 | @Produces(MediaType.APPLICATION_JSON) 29 | public AtupTestCaseListInfo getCases(@QueryParam("start") final Integer start, @QueryParam("size") final Integer size) { 30 | if (start == null || size == null) { 31 | return new AtupTestCaseListInfo(AtupErrorInfo.INVALID_PARAM, AtupErrorCode.INVALID_PARAM); 32 | } 33 | return service.getCases(start, size); 34 | } 35 | 36 | @POST 37 | @Produces(MediaType.APPLICATION_JSON) 38 | @Consumes(MediaType.APPLICATION_JSON) 39 | public AtupTestCase createSuite(final AtupTestCase testCase) { 40 | try { 41 | return service.createSuite(testCase); 42 | } catch (final Exception e) { 43 | log.error(e); 44 | return null; 45 | } 46 | } 47 | 48 | @GET 49 | @Path("{caseName}") 50 | @Produces(MediaType.APPLICATION_JSON) 51 | public AtupTestCase getCases(@PathParam("caseName") final String caseName) { 52 | try { 53 | return service.getCaseByName(caseName); 54 | } catch (final Exception e) { 55 | return null; 56 | } 57 | } 58 | 59 | @PUT 60 | @Produces(MediaType.APPLICATION_JSON) 61 | @Consumes(MediaType.APPLICATION_JSON) 62 | public AtupTestCase updateSuite(final AtupTestCase testCase) { 63 | try { 64 | return service.updateSuite(testCase); 65 | } catch (final Exception e) { 66 | log.error(e); 67 | return null; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/resource/AtupTestResultResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.cases.service.AtupTestResultService; 4 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 5 | import org.feuyeux.jaxrs2.atup.core.info.AtupErrorCode; 6 | import org.feuyeux.jaxrs2.atup.core.info.AtupErrorInfo; 7 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestResultListInfo; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | import javax.ws.rs.GET; 12 | import javax.ws.rs.Path; 13 | import javax.ws.rs.Produces; 14 | import javax.ws.rs.QueryParam; 15 | import javax.ws.rs.core.Context; 16 | import javax.ws.rs.core.HttpHeaders; 17 | import javax.ws.rs.core.MediaType; 18 | 19 | @Component 20 | @Path(AtupApi.TEST_RESULT_PATH) 21 | public class AtupTestResultResource { 22 | @Autowired 23 | AtupTestResultService service; 24 | 25 | @GET 26 | @Path("results") 27 | @Produces(MediaType.APPLICATION_JSON) 28 | public AtupTestResultListInfo getResultsByUser(@Context final HttpHeaders headers, @QueryParam("start") final Integer start, 29 | @QueryParam("size") final Integer size) { 30 | final String userId = headers.getRequestHeader("Atup-User").get(0); 31 | if (start == null || size == null) { 32 | return new AtupTestResultListInfo(AtupErrorInfo.INVALID_PARAM, AtupErrorCode.INVALID_PARAM); 33 | } 34 | return service.getResults(Integer.valueOf(userId), start, size); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/resource/AtupTestSuiteResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.cases.service.AtupTestSuiteService; 4 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 6 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestSuiteListInfo; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.ws.rs.*; 11 | import javax.ws.rs.core.MediaType; 12 | 13 | @Component 14 | @Path(AtupApi.TEST_SUITE_PATH) 15 | public class AtupTestSuiteResource { 16 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(AtupTestSuiteResource.class.getName()); 17 | @Autowired 18 | private AtupTestSuiteService service; 19 | 20 | @GET 21 | @Path("suites") 22 | @Produces(MediaType.APPLICATION_JSON) 23 | public AtupTestSuiteListInfo getCases(@QueryParam("start") final Integer start, @QueryParam("size") final Integer size) { 24 | return service.getSuites(start, size); 25 | } 26 | 27 | @POST 28 | @Produces(MediaType.APPLICATION_JSON) 29 | @Consumes(MediaType.APPLICATION_JSON) 30 | public AtupTestSuite createSuite(final AtupTestSuite testSuite) { 31 | try { 32 | return service.createSuite(testSuite); 33 | } catch (final Exception e) { 34 | log.error(e); 35 | return null; 36 | } 37 | } 38 | 39 | @PUT 40 | @Produces(MediaType.APPLICATION_JSON) 41 | @Consumes(MediaType.APPLICATION_JSON) 42 | public AtupTestSuite updateSuite(final AtupTestSuite testSuite) { 43 | try { 44 | return service.updateSuite(testSuite); 45 | } catch (final Exception e) { 46 | log.error(e); 47 | return null; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/runner/LaunchTestRunner.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.runner; 2 | 3 | import org.feuyeux.jaxrs2.atup.cases.service.JobLaunchService; 4 | 5 | import java.util.concurrent.Callable; 6 | 7 | public class LaunchTestRunner implements Callable { 8 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LaunchTestRunner.class.getName()); 9 | private final JobLaunchService service; 10 | 11 | public LaunchTestRunner(JobLaunchService service) { 12 | this.service = service; 13 | } 14 | 15 | @Override 16 | public Boolean call() throws Exception { 17 | try { 18 | return service.launch(); 19 | } catch (final Exception e) { 20 | log.error(e); 21 | return false; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/service/AtupTestCaseService.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.service; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 5 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestCaseListInfo; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Calendar; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | @Service 14 | public class AtupTestCaseService { 15 | @Autowired 16 | org.feuyeux.jaxrs2.atup.core.dao.AtupTestCaseDao dao; 17 | @Autowired 18 | org.feuyeux.jaxrs2.atup.core.dao.AtupTestSuiteDao suiteDao; 19 | 20 | public boolean deleteTestCase(final Integer testCaseId) { 21 | return dao.remove(testCaseId); 22 | } 23 | 24 | public AtupTestCase createTestCase(final AtupTestCase testCase) { 25 | return dao.save(testCase); 26 | } 27 | 28 | public AtupTestCase updateTestCase(final AtupTestCase testCase) { 29 | return dao.update(testCase); 30 | } 31 | 32 | public AtupTestCaseListInfo getCases(final Integer start, final Integer size) { 33 | AtupTestCaseListInfo result; 34 | final List list = dao.findAll(start, size); 35 | if (list != null && list.size() > 0) { 36 | result = new AtupTestCaseListInfo(list); 37 | } else { 38 | result = new AtupTestCaseListInfo(); 39 | } 40 | return result; 41 | } 42 | 43 | public AtupTestCase createSuite(final AtupTestCase testCase) { 44 | final AtupTestSuite editingTestSuite = suiteDao.findById(testCase.getSuite().getSuiteId()); 45 | testCase.setSuite(editingTestSuite); 46 | final Date time = Calendar.getInstance().getTime(); 47 | testCase.setCreateTime(time); 48 | testCase.setUpdateTime(time); 49 | return dao.save(testCase); 50 | } 51 | 52 | public AtupTestCase getCaseByName(final String caseName) { 53 | return dao.findByName(caseName); 54 | } 55 | 56 | public AtupTestCase updateSuite(final AtupTestCase testCase) { 57 | final AtupTestSuite editingTestSuite = suiteDao.findById(testCase.getSuite().getSuiteId()); 58 | testCase.setSuite(editingTestSuite); 59 | return dao.update(testCase); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/service/AtupTestResultService.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.service; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestResultDao; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 5 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestResultListInfo; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | 11 | @Service 12 | public class AtupTestResultService { 13 | @Autowired 14 | AtupTestResultDao dao; 15 | 16 | public AtupTestResultListInfo getResults(final Integer userId, final Integer start, final Integer size) { 17 | AtupTestResultListInfo result; 18 | final List list = dao.findByUser(userId, start, size); 19 | if (list != null && list.size() > 0) { 20 | result = new AtupTestResultListInfo(list); 21 | } else { 22 | result = new AtupTestResultListInfo(); 23 | } 24 | return result; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /atup-case/src/main/java/org/feuyeux/jaxrs2/atup/cases/service/AtupTestSuiteService.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.service; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestSuiteDao; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 5 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestSuiteInfo; 6 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestSuiteListInfo; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | @Service 14 | public class AtupTestSuiteService { 15 | 16 | @Autowired 17 | AtupTestSuiteDao dao; 18 | 19 | public AtupTestSuiteListInfo getSuites(final Integer start, final Integer size) { 20 | AtupTestSuiteListInfo result; 21 | final List list = dao.findAll(start, size); 22 | if (list != null && list.size() > 0) { 23 | final List suiteInfoList = new ArrayList<>(list.size()); 24 | for (final AtupTestSuite testSuite : list) { 25 | final AtupTestSuiteInfo caseInfo = new AtupTestSuiteInfo(testSuite); 26 | suiteInfoList.add(caseInfo); 27 | } 28 | result = new AtupTestSuiteListInfo(); 29 | result.setSuiteList(suiteInfoList); 30 | } else { 31 | result = new AtupTestSuiteListInfo(); 32 | } 33 | return result; 34 | } 35 | 36 | public AtupTestSuite createSuite(final AtupTestSuite testSuite) { 37 | return dao.save(testSuite); 38 | } 39 | 40 | public AtupTestSuite updateSuite(final AtupTestSuite testSuite) { 41 | return dao.update(testSuite); 42 | } 43 | } -------------------------------------------------------------------------------- /atup-case/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.eclipse.persistence.jpa.PersistenceProvider 7 | java:/comp/env/jdbc/AtupDataSource 8 | java:/comp/env/jdbc/AtupDataSource 9 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 10 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 11 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 12 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 13 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | org.eclipse.persistence.jpa.PersistenceProvider 22 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 23 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 24 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 25 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 26 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /atup-case/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /atup-case/src/main/resources/applicationContext2.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /atup-case/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %p %c{1.} [%t] %m %ex%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /atup-case/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | ATUP Case Management 6 | 7 | Container 8 | jdbc/AtupDataSource 9 | javax.sql.DataSource 10 | 11 | 12 | -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/ConcurrentTaskTest.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.*; 5 | import java.util.concurrent.*; 6 | 7 | class ConcurrentTaskTest { 8 | public static void main(String[] args) throws ExecutionException, InterruptedException { 9 | List tasks = new ArrayList<>(); 10 | ConcurrentHashMap map = new ConcurrentHashMap<>(); 11 | int n = 5; 12 | for (int i = 0; i < 20; i++) { 13 | map.put("" + i, "" + i); 14 | } 15 | for (int i = 0; i < n; i++) { 16 | tasks.add(new TestRunner(i + "-Runner", map)); 17 | } 18 | ExecutorService executorService = Executors.newFixedThreadPool(n); 19 | List> resultFutures = executorService.invokeAll(tasks); 20 | 21 | for (int i = 0; i < n; i++) { 22 | System.out.println(resultFutures.get(i).get()); 23 | } 24 | executorService.shutdown(); 25 | } 26 | } 27 | 28 | class TestRunner implements Callable { 29 | private final String name; 30 | private final ConcurrentHashMap map; 31 | 32 | private final SimpleDateFormat f = new SimpleDateFormat("HH:mm:ss SSS"); 33 | 34 | TestRunner(String name, ConcurrentHashMap map) { 35 | this.name = name; 36 | this.map = map; 37 | } 38 | 39 | @Override 40 | public String call() throws Exception { 41 | final Iterator> iterator = map.entrySet().iterator(); 42 | StringBuilder r = new StringBuilder(name); 43 | while (iterator.hasNext()) { 44 | final Map.Entry kv = iterator.next(); 45 | String value = map.remove(kv.getKey()); 46 | if (value != null) { 47 | r.append(" get ").append(value); 48 | r.append(" at ").append(f.format(new Date())).append("; "); 49 | } 50 | } 51 | return r.toString(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/dao/TUTestCaseDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestCaseDao; 5 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestSuiteDao; 6 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 7 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 8 | import org.feuyeux.jaxrs2.atup.core.fake.CreatTestSuite; 9 | import org.feuyeux.jaxrs2.atup.core.fake.CreateTestCase; 10 | import org.junit.Assert; 11 | import org.junit.Before; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.test.context.ContextConfiguration; 16 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 17 | 18 | import java.util.List; 19 | 20 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 21 | @RunWith(SpringJUnit4ClassRunner.class) 22 | public class TUTestCaseDao { 23 | @Autowired 24 | AtupTestSuiteDao sdao; 25 | @Autowired 26 | AtupTestCaseDao dao; 27 | 28 | static final AtupTestSuite one = CreatTestSuite.buildOneTestSuite(); 29 | static boolean saved = false; 30 | 31 | @Before 32 | public void tearUp() { 33 | if (!saved) { 34 | sdao.save(one); 35 | saved=true; 36 | } 37 | } 38 | 39 | @Test 40 | public void testCreateTestCase() { 41 | String caseName = "TEST35" + System.nanoTime(); 42 | final AtupTestCase entity = CreateTestCase.buildTestCase(one, caseName); 43 | final AtupTestCase savedEntity = dao.save(entity); 44 | Assert.assertEquals(caseName, savedEntity.getCaseName()); 45 | final boolean deleted = dao.remove(savedEntity.getCaseId()); 46 | Assert.assertEquals(true, deleted); 47 | } 48 | 49 | @Test 50 | public void testUpdateTestCase() { 51 | String caseName = "TEST35" + System.nanoTime(); 52 | final AtupTestCase entity = CreateTestCase.buildTestCase(one, caseName); 53 | final AtupTestCase savedEntity = dao.save(entity); 54 | savedEntity.setCaseStatus(AtupParam.DISABLED_CASE); 55 | final AtupTestCase updatedEntity = dao.update(savedEntity); 56 | Assert.assertEquals(AtupParam.DISABLED_CASE, updatedEntity.getCaseStatus()); 57 | final boolean deleted = dao.remove(savedEntity.getCaseId()); 58 | Assert.assertEquals(true, deleted); 59 | } 60 | 61 | @Test 62 | public void findByName() { 63 | final AtupTestCase testCase = dao.findByName(CreateTestCase.CASE_NAME); 64 | Assert.assertEquals(CreateTestCase.CASE_NAME, testCase.getCaseName()); 65 | } 66 | 67 | @Test 68 | public void findByStatus() { 69 | final List caseList = dao.findByStatus(AtupParam.NORMAL_CASE); 70 | if (!caseList.isEmpty()) { 71 | Assert.assertEquals(AtupParam.NORMAL_CASE, caseList.get(0).getCaseStatus()); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/dao/TUTestResultDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestCaseDao; 5 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestResultDao; 6 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestSuiteDao; 7 | import org.feuyeux.jaxrs2.atup.core.dao.AtupUserDao; 8 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 9 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 10 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 11 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 12 | import org.feuyeux.jaxrs2.atup.core.fake.CreatTestSuite; 13 | import org.feuyeux.jaxrs2.atup.core.fake.CreateTestCase; 14 | import org.feuyeux.jaxrs2.atup.core.fake.CreateTestResult; 15 | import org.feuyeux.jaxrs2.atup.core.fake.CreateUser; 16 | import org.junit.Assert; 17 | import org.junit.Before; 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.test.context.ContextConfiguration; 22 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 23 | 24 | import java.util.List; 25 | 26 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 27 | @RunWith(SpringJUnit4ClassRunner.class) 28 | public class TUTestResultDao { 29 | public static final String CASE_NAME = "TEST2014" + System.nanoTime(); 30 | @Autowired 31 | AtupTestResultDao dao; 32 | @Autowired 33 | AtupTestSuiteDao sdao; 34 | @Autowired 35 | AtupTestCaseDao cdao; 36 | @Autowired 37 | AtupUserDao udao; 38 | 39 | static AtupTestSuite suite; 40 | static AtupTestCase one; 41 | static AtupUser user; 42 | static boolean saved = false; 43 | 44 | @Before 45 | public void tearUp() { 46 | if (!saved) { 47 | user = CreateUser.buildUser(); 48 | udao.save(user); 49 | String suiteName = "Test_Suite_N" + System.nanoTime(); 50 | suite = CreatTestSuite.buildOneTestSuite(suiteName); 51 | sdao.save(suite); 52 | one = CreateTestCase.buildOneTestCase(suite, CASE_NAME); 53 | cdao.save(one); 54 | saved = true; 55 | } 56 | } 57 | 58 | @Test 59 | public void testCreateResult() { 60 | final AtupTestResult entity = CreateTestResult.buildTestResult(one, user); 61 | final AtupTestResult savedEntity = dao.save(entity); 62 | Assert.assertEquals(CASE_NAME, savedEntity.getTestCase().getCaseName()); 63 | final boolean deleted = dao.remove(savedEntity.getResultId()); 64 | Assert.assertEquals(true, deleted); 65 | } 66 | 67 | @Test 68 | public void testUpdateTestResult() { 69 | final AtupTestResult entity = CreateTestResult.buildTestResult(one, user); 70 | final AtupTestResult savedEntity = dao.save(entity); 71 | savedEntity.setResultStatus(AtupParam.RESULT_FAILED); 72 | final AtupTestResult updatedEntity = dao.update(savedEntity); 73 | Assert.assertEquals(AtupParam.RESULT_FAILED, updatedEntity.getResultStatus()); 74 | final boolean deleted = dao.remove(updatedEntity.getResultId()); 75 | Assert.assertEquals(true, deleted); 76 | } 77 | 78 | @Test 79 | public void testFindByStatus() { 80 | final List resultList = dao.findByStatus(AtupParam.RESULT_SUCCESS); 81 | checkResult(resultList); 82 | } 83 | 84 | private void checkResult(final List resultList) { 85 | if (!resultList.isEmpty()) { 86 | Assert.assertEquals(AtupParam.RESULT_SUCCESS, resultList.get(0).getResultStatus()); 87 | } 88 | } 89 | 90 | @Test 91 | public void testFindByTestResult() { 92 | final AtupTestSuite suite = CreatTestSuite.buildTestSuite(); 93 | final List resultList = dao.findByTestCase(CreateTestCase.buildTestCase(suite)); 94 | checkResult(resultList); 95 | } 96 | 97 | @Test 98 | public void testFindByUser() { 99 | final List resultList = dao.findByUser(CreateUser.buildUser().getUserId(), 0, 100); 100 | checkResult(resultList); 101 | } 102 | } -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/dao/TUTestSuiteDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.dao.AtupTestSuiteDao; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 6 | import org.feuyeux.jaxrs2.atup.core.fake.CreatTestSuite; 7 | import org.junit.Assert; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.test.context.ContextConfiguration; 12 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 13 | 14 | import java.util.List; 15 | 16 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 17 | @RunWith(SpringJUnit4ClassRunner.class) 18 | public class TUTestSuiteDao { 19 | @Autowired 20 | 21 | AtupTestSuiteDao dao; 22 | 23 | @Test 24 | public void testCreateTestSuite() { 25 | final AtupTestSuite entity = CreatTestSuite.buildTestSuite(); 26 | dao.save(entity); 27 | } 28 | 29 | @Test 30 | public void testUpdateTestSuite() { 31 | final AtupTestSuite entity = CreatTestSuite.buildTestSuite(); 32 | final AtupTestSuite savedEntity = dao.save(entity); 33 | savedEntity.setSuiteType(AtupParam.EDGE_SUITE); 34 | final AtupTestSuite updatedEntity = dao.update(savedEntity); 35 | Assert.assertEquals(AtupParam.EDGE_SUITE, updatedEntity.getSuiteType()); 36 | } 37 | 38 | @Test 39 | public void testDeleteTestSuite() { 40 | final AtupTestSuite entity = CreatTestSuite.buildTestSuite(); 41 | final AtupTestSuite savedEntity = dao.save(entity); 42 | final boolean deleted = dao.remove(savedEntity.getSuiteId()); 43 | Assert.assertEquals(true, deleted); 44 | } 45 | 46 | @Test 47 | public void testFindByName() { 48 | final AtupTestSuite suite = dao.findBySuiteName(CreatTestSuite.SUITE_NAME); 49 | Assert.assertEquals(CreatTestSuite.SUITE_NAME, suite.getSuiteName()); 50 | } 51 | 52 | @Test 53 | public void testFindByStatus() { 54 | final List suiteList = dao.findByStatus(AtupParam.NORMAL_SUITE); 55 | Assert.assertEquals(AtupParam.NORMAL_SUITE, suiteList.get(0).getSuiteStatus()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/resource/TITestCaseResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 5 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestCaseListInfo; 6 | import org.glassfish.jersey.server.ResourceConfig; 7 | import org.glassfish.jersey.test.JerseyTest; 8 | import org.glassfish.jersey.test.TestProperties; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | import javax.ws.rs.client.Invocation; 16 | import javax.ws.rs.client.WebTarget; 17 | import javax.ws.rs.core.Application; 18 | import javax.ws.rs.core.MediaType; 19 | import java.util.List; 20 | 21 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 22 | @RunWith(SpringJUnit4ClassRunner.class) 23 | public class TITestCaseResource extends JerseyTest { 24 | @Override 25 | protected Application configure() { 26 | enable(TestProperties.LOG_TRAFFIC); 27 | enable(TestProperties.DUMP_ENTITY); 28 | return new ResourceConfig(AtupTestCaseResource.class); 29 | } 30 | 31 | @Test 32 | public void testGetList() { 33 | final WebTarget webTarget = target(AtupApi.TEST_CASE_PATH).path("cases").queryParam("start", 0).queryParam("size", 100); 34 | final Invocation.Builder request = webTarget.request(MediaType.APPLICATION_JSON_TYPE); 35 | final AtupTestCaseListInfo result = request.get(AtupTestCaseListInfo.class); 36 | final List testCaseList = result.getTestCaseList(); 37 | if (testCaseList != null && testCaseList.size() > 0) { 38 | Assert.assertNotNull(testCaseList.get(0).getCaseId()); 39 | } else { 40 | Assert.assertTrue(testCaseList == null || result.getErrorInfo() != null); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/resource/TITestResultResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 5 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestResultListInfo; 6 | import org.glassfish.jersey.server.ResourceConfig; 7 | import org.glassfish.jersey.test.JerseyTest; 8 | import org.glassfish.jersey.test.TestProperties; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | import javax.ws.rs.client.Invocation; 16 | import javax.ws.rs.client.WebTarget; 17 | import javax.ws.rs.core.Application; 18 | import javax.ws.rs.core.MediaType; 19 | import java.util.List; 20 | 21 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 22 | @RunWith(SpringJUnit4ClassRunner.class) 23 | public class TITestResultResource extends JerseyTest { 24 | @Override 25 | protected Application configure() { 26 | enable(TestProperties.LOG_TRAFFIC); 27 | enable(TestProperties.DUMP_ENTITY); 28 | return new ResourceConfig(AtupTestResultResource.class); 29 | } 30 | 31 | @Test 32 | public void testGetList() { 33 | final WebTarget webTarget = target(AtupApi.TEST_RESULT_PATH).path("results").queryParam("start", 0).queryParam("size", 100); 34 | final Invocation.Builder request = webTarget.request(MediaType.APPLICATION_JSON_TYPE); 35 | final AtupTestResultListInfo result = request.get(AtupTestResultListInfo.class); 36 | final List testResultList = result.getResultList(); 37 | if (testResultList != null && testResultList.size() > 0) { 38 | Assert.assertNotNull(testResultList.get(0).getResultId()); 39 | } else { 40 | Assert.assertTrue(testResultList == null || result.getErrorInfo() != null); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/resource/TITestSuiteResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 4 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestSuiteInfo; 5 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestSuiteListInfo; 6 | import org.glassfish.jersey.server.ResourceConfig; 7 | import org.glassfish.jersey.test.JerseyTest; 8 | import org.glassfish.jersey.test.TestProperties; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | import javax.ws.rs.client.Invocation; 16 | import javax.ws.rs.client.WebTarget; 17 | import javax.ws.rs.core.Application; 18 | import javax.ws.rs.core.MediaType; 19 | import java.util.List; 20 | 21 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 22 | @RunWith(SpringJUnit4ClassRunner.class) 23 | public class TITestSuiteResource extends JerseyTest { 24 | @Override 25 | protected Application configure() { 26 | enable(TestProperties.LOG_TRAFFIC); 27 | enable(TestProperties.DUMP_ENTITY); 28 | return new ResourceConfig(AtupTestSuiteResource.class); 29 | } 30 | 31 | @Test 32 | public void testGetList() { 33 | final WebTarget webTarget = target(AtupApi.TEST_RESULT_PATH).path("results").queryParam("start", 0).queryParam("size", 100); 34 | final Invocation.Builder request = webTarget.request(MediaType.APPLICATION_JSON_TYPE); 35 | final AtupTestSuiteListInfo result = request.get(AtupTestSuiteListInfo.class); 36 | final List testSuiteList = result.getSuiteList(); 37 | if (testSuiteList != null && testSuiteList.size() > 0) { 38 | Assert.assertNotNull(testSuiteList.get(0).getSuiteId()); 39 | } else { 40 | Assert.assertTrue(testSuiteList == null || result.getErrorInfo() != null); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /atup-case/src/test/java/org/feuyeux/jaxrs2/atup/cases/service/TUJobQueue.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.cases.service; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.info.AtupTestJobInfo; 4 | import org.junit.Test; 5 | 6 | import java.util.Arrays; 7 | import java.util.PriorityQueue; 8 | import java.util.Random; 9 | import java.util.concurrent.atomic.AtomicInteger; 10 | 11 | /** 12 | * User: Eric Han 13 | * Date: 1/17/14 14 | * Time: 12:22 AM 15 | */ 16 | public class TUJobQueue { 17 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(TUJobQueue.class.getName()); 18 | final PriorityQueue jobQueue = new PriorityQueue<>(); 19 | final Random random = new Random(System.nanoTime()); 20 | static final AtomicInteger JOB_ID = new AtomicInteger(); 21 | 22 | @Test 23 | public void testJobQueue() { 24 | for (int i = 0; i < 10; i++) { 25 | Integer userId = 1; 26 | String deviceIp = "10.11.10." + i; 27 | Integer caseId = i; 28 | Integer priority = random.nextInt(5); 29 | AtupTestJobInfo jobInfo = new AtupTestJobInfo(userId, deviceIp, caseId, priority, System.nanoTime()); 30 | jobInfo.setJobId(JOB_ID.getAndIncrement()); 31 | jobQueue.offer(jobInfo); 32 | } 33 | 34 | AtupTestJobInfo[] jobs = jobQueue.toArray(new AtupTestJobInfo[jobQueue.size()]); 35 | if (jobs.length > 0) { 36 | Arrays.sort(jobs); 37 | } 38 | 39 | log.debug("********"); 40 | for (AtupTestJobInfo job : jobs) { 41 | log.debug(job.toString()); 42 | } 43 | 44 | log.debug("********"); 45 | while (jobQueue.size() > 0) { 46 | log.debug(jobQueue.poll()); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /atup-core/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.feuyeux.jaxrs2.atup 6 | atup 7 | 0.0.4-SNAPSHOT 8 | 9 | 10 | atup-core 11 | jar 12 | ATUP Core 13 | 14 | 15 | 16 | 17 | org.apache.tomcat 18 | tomcat-servlet-api 19 | provided 20 | 21 | 22 | 23 | org.glassfish.jersey.containers 24 | jersey-container-servlet 25 | 26 | 27 | 28 | org.glassfish.jersey.media 29 | jersey-media-moxy 30 | 31 | 32 | 33 | org.glassfish.jersey.ext 34 | jersey-spring3 35 | 36 | 37 | 38 | org.springframework 39 | spring-core 40 | 41 | 42 | org.springframework 43 | spring-web 44 | compile 45 | 46 | 47 | org.springframework 48 | spring-test 49 | test 50 | 51 | 52 | org.springframework 53 | spring-tx 54 | 55 | 56 | org.springframework 57 | spring-orm 58 | 59 | 60 | 61 | mysql 62 | mysql-connector-java 63 | 64 | 65 | org.eclipse.persistence 66 | eclipselink 67 | 68 | 69 | 70 | org.apache.logging.log4j 71 | log4j-api 72 | 73 | 74 | org.apache.logging.log4j 75 | log4j-core 76 | 77 | 78 | org.glassfish.jersey.connectors 79 | jersey-apache-connector 80 | 81 | 82 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/constant/AtupApi.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.constant; 2 | 3 | public interface AtupApi { 4 | String PROTOCOL = "http://"; 5 | String SERVICE_PORT = "8080"; 6 | String SERVICE_PATH = "/atup-test-station/rest-api/station"; 7 | String TEST_SUITE_PATH = "testsuites"; 8 | String TEST_CASE_PATH = "testcases"; 9 | String TEST_JOB_PATH = "testjobs"; 10 | String TEST_RESULT_PATH = "testresults"; 11 | String USER_PATH = "users"; 12 | String DEVICE_PATH = "devices"; 13 | String TEST_STATION_CONTEXT = "atup-test-station"; 14 | String TEST_STATION_PATH = "station"; 15 | String ATUP_USER_HEAD = "Atup-User"; 16 | String ATUP_USER_ROLE_HEAD = "Atup-UserRole"; 17 | } 18 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/constant/AtupParam.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.constant; 2 | 3 | public interface AtupParam { 4 | /*Test Suite*/ 5 | Integer NORMAL_SUITE = 1; 6 | Integer PERFORMANCE_SUITE = 2; 7 | Integer EDGE_SUITE = 3; 8 | 9 | /*Test Case*/ 10 | Integer NORMAL_CASE = 0; 11 | Integer DISABLED_CASE = 1; 12 | 13 | /*User*/ 14 | Integer USER_ADMIN = 1; 15 | Integer USER_JOB_KILLER = 2; 16 | Integer USER_DEVICE_MANAGER = 3; 17 | Integer USER_USER = 4; 18 | 19 | Integer NORMAL_USER = 0; 20 | Integer DISABLED_USER = 1; 21 | 22 | /*Device */ 23 | Integer DEVICE_IDLE = 0; 24 | Integer DEVICE_RUNNING = 1; 25 | Integer DEVICE_ERROR = 2; 26 | 27 | Integer DEVICE_SPEED = 10; 28 | Integer DEVICE_SMOCKING = 11; 29 | Integer DEVICE_SANITY = 12; 30 | Integer DEVICE_REGRESSIVE = 13; 31 | Integer DEVICE_QUALITY = 20; 32 | Integer DEVICE_SYSTEM = 21; 33 | Integer DEVICE_PERFORMANCE = 22; 34 | 35 | /*Test Result*/ 36 | Integer RESULT_SUCCESS = 0; 37 | Integer RESULT_FAILED = 1; 38 | Integer RESULT_UNKOWN = 2; 39 | 40 | /*Test Job*/ 41 | Integer HIGH = 0; 42 | Integer MEDIUM = 1; 43 | Integer LOW = 2; 44 | } 45 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/constant/AtupVariable.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.constant; 2 | 3 | public interface AtupVariable { 4 | long DETECT_INTERVAL = 10;//10 seconds 5 | int DETECT_CONNECT_TIMEOUT = 20;//20 seconds 6 | long TESTING_TIMEOUT = 10000;//10 seconds 7 | long ASYNC_LAUNCH_TEST_TIMEOUT = 300000;//5 minutes 8 | } 9 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/dao/AtupDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.dao; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.springframework.transaction.annotation.Transactional; 6 | import org.springframework.util.Assert; 7 | 8 | import javax.persistence.EntityManager; 9 | import javax.persistence.PersistenceContext; 10 | import javax.persistence.TypedQuery; 11 | import javax.persistence.criteria.CriteriaBuilder; 12 | import javax.persistence.criteria.CriteriaQuery; 13 | import java.lang.reflect.ParameterizedType; 14 | import java.lang.reflect.Type; 15 | import java.util.List; 16 | 17 | public class AtupDao { 18 | private final Logger log = LogManager.getLogger(AtupDao.class.getName()); 19 | @PersistenceContext 20 | EntityManager entityManager; 21 | private Class entityClass; 22 | 23 | @SuppressWarnings("unchecked") 24 | public AtupDao() { 25 | final Type genericSuperclass = getClass().getGenericSuperclass(); 26 | if (genericSuperclass instanceof ParameterizedType) { 27 | final ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass; 28 | final Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); 29 | this.entityClass = (Class) actualTypeArguments[0]; 30 | } 31 | } 32 | 33 | public T findById(final Integer id) { 34 | Assert.notNull(id); 35 | try { 36 | return entityManager.find(entityClass, id); 37 | } catch (final Exception e) { 38 | log.error(e); 39 | return null; 40 | } 41 | } 42 | 43 | public List findAll() { 44 | return findAll(false, 0, 0); 45 | } 46 | 47 | public List findAll(final int firstResult, final int maxResults) { 48 | return findAll(true, firstResult, maxResults); 49 | } 50 | 51 | private List findAll(final boolean isPaging, final int firstResult, final int maxResults) { 52 | final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); 53 | final CriteriaQuery cq = cb.createQuery(entityClass); 54 | final TypedQuery q = entityManager.createQuery(cq); 55 | if (isPaging) { 56 | q.setMaxResults(maxResults); 57 | q.setFirstResult(firstResult); 58 | } 59 | return q.getResultList(); 60 | } 61 | 62 | @Transactional 63 | public boolean remove(final Integer entityId) { 64 | final T entity = findById(entityId); 65 | if (entity != null) { 66 | entityManager.remove(entity); 67 | return true; 68 | } else { 69 | return false; 70 | } 71 | } 72 | 73 | @Transactional 74 | public T save(final T entity) { 75 | entityManager.persist(entity); 76 | entityManager.flush(); 77 | return entity; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/dao/AtupDeviceDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupDevice; 4 | import org.springframework.stereotype.Repository; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | import javax.persistence.TypedQuery; 8 | import java.util.Calendar; 9 | import java.util.List; 10 | 11 | @Repository 12 | public class AtupDeviceDao extends AtupDao { 13 | public AtupDeviceDao() { 14 | super(); 15 | } 16 | 17 | public AtupDevice findByIp(final String deviceHost) { 18 | final TypedQuery atupDeviceTypedQuery = entityManager.createNamedQuery("findByDeviceIp", AtupDevice.class).setParameter("deviceHost", 19 | deviceHost); 20 | atupDeviceTypedQuery.setHint("javax.persistence.cache.storeMode", "REFRESH"); 21 | return atupDeviceTypedQuery.getSingleResult(); 22 | } 23 | 24 | public List findDevicesByUser(final Integer userId) { 25 | return entityManager.createNamedQuery("findDevicesByUser", AtupDevice.class).setParameter("userId", userId).getResultList(); 26 | } 27 | 28 | @Transactional 29 | public AtupDevice update(final AtupDevice entity) { 30 | final AtupDevice updateEntity = findByIp(entity.getDeviceHost()); 31 | if (updateEntity != null) { 32 | entity.setDeviceId(updateEntity.getDeviceId()); 33 | entity.setUpdateTime(Calendar.getInstance().getTime()); 34 | entity.setCreateTime(updateEntity.getCreateTime()); 35 | return entityManager.merge(entity); 36 | } else { 37 | return null; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/dao/AtupTestCaseDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 4 | import org.springframework.stereotype.Repository; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | import java.util.Calendar; 8 | import java.util.List; 9 | 10 | @Repository 11 | public class AtupTestCaseDao extends AtupDao { 12 | public AtupTestCaseDao() { 13 | super(); 14 | } 15 | 16 | public List findByStatus(final Integer caseStatus) { 17 | return entityManager.createNamedQuery("findByStatus", AtupTestCase.class).setParameter("caseStatus", caseStatus).getResultList(); 18 | } 19 | 20 | public AtupTestCase findByName(final String caseName) { 21 | return entityManager.createNamedQuery("findByName", AtupTestCase.class).setParameter("caseName", caseName).getSingleResult(); 22 | } 23 | 24 | @Transactional 25 | public AtupTestCase update(final AtupTestCase entity) { 26 | final AtupTestCase updateEntity = findByName(entity.getCaseName()); 27 | if (updateEntity != null) { 28 | entity.setCaseId(updateEntity.getCaseId()); 29 | entity.setUpdateTime(Calendar.getInstance().getTime()); 30 | entity.setCreateTime(updateEntity.getCreateTime()); 31 | return entityManager.merge(entity); 32 | } else { 33 | return null; 34 | } 35 | } 36 | 37 | @Transactional 38 | public AtupTestCase update2(final AtupTestCase entity) { 39 | return entityManager.merge(entity); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/dao/AtupTestResultDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 5 | import org.springframework.stereotype.Repository; 6 | import org.springframework.transaction.annotation.Transactional; 7 | 8 | import javax.persistence.TypedQuery; 9 | import java.util.Calendar; 10 | import java.util.List; 11 | 12 | @Repository 13 | public class AtupTestResultDao extends AtupDao { 14 | 15 | public AtupTestResultDao() { 16 | } 17 | 18 | public List findByStatus(final Integer resultStatus) { 19 | return entityManager.createNamedQuery("findResultByStatus", AtupTestResult.class).setParameter("resultStatus", resultStatus).getResultList(); 20 | } 21 | 22 | public List findByUser(final Integer userId, final Integer start, final Integer size) { 23 | final TypedQuery query = entityManager.createNamedQuery("findResultByUser", AtupTestResult.class).setParameter("userId", userId); 24 | query.setFirstResult(start); 25 | query.setMaxResults(size); 26 | return query.getResultList(); 27 | } 28 | 29 | public List findByTestCase(final AtupTestCase testCase) { 30 | return entityManager.createNamedQuery("findResultByTestCase", AtupTestResult.class).setParameter("testCase", testCase).getResultList(); 31 | } 32 | 33 | @Transactional 34 | public AtupTestResult update(final AtupTestResult entity) { 35 | entity.setUpdateTime(Calendar.getInstance().getTime()); 36 | //entity.setCreateTime(updateEntity.getCreateTime()); 37 | return entityManager.merge(entity); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/dao/AtupTestSuiteDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 4 | import org.springframework.stereotype.Repository; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public class AtupTestSuiteDao extends AtupDao { 11 | public AtupTestSuiteDao() { 12 | super(); 13 | } 14 | 15 | public List findByStatus(final Integer suiteStatus) { 16 | return entityManager.createNamedQuery("findBySuiteStatus", AtupTestSuite.class).setParameter("suiteStatus", suiteStatus).getResultList(); 17 | } 18 | 19 | public AtupTestSuite findBySuiteName(final String suiteName) { 20 | return entityManager.createNamedQuery("findBySuiteName", AtupTestSuite.class).setParameter("suiteName", suiteName).getSingleResult(); 21 | } 22 | 23 | @Transactional 24 | public AtupTestSuite update(final AtupTestSuite entity) { 25 | final AtupTestSuite updateEntity = findBySuiteName(entity.getSuiteName()); 26 | if (updateEntity != null) { 27 | entity.setSuiteId(updateEntity.getSuiteId()); 28 | return entityManager.merge(entity); 29 | } else { 30 | return null; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/dao/AtupUserDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 4 | import org.springframework.stereotype.Repository; 5 | import org.springframework.transaction.annotation.Transactional; 6 | 7 | @Repository 8 | public class AtupUserDao extends AtupDao { 9 | public AtupUserDao() { 10 | super(); 11 | } 12 | 13 | public AtupUser findByName(final String userName) { 14 | return entityManager.createNamedQuery("findByUserName", AtupUser.class).setParameter("userName", userName).getSingleResult(); 15 | } 16 | 17 | @Transactional 18 | public AtupUser update(final AtupUser entity) { 19 | final AtupUser updateEntity; 20 | try { 21 | if (entity.getUserId() != null) { 22 | updateEntity = findById(entity.getUserId()); 23 | } else { 24 | updateEntity = findByName(entity.getUserName()); 25 | } 26 | 27 | if (updateEntity != null) { 28 | if (entity.getStatus() != null) { 29 | updateEntity.setStatus(entity.getStatus()); 30 | } 31 | if (entity.getUserName() != null) { 32 | updateEntity.setUserName(entity.getUserName()); 33 | } 34 | if (entity.getPassWord() != null) { 35 | updateEntity.setPassWord(entity.getPassWord()); 36 | } 37 | if (entity.getUserRole() != null) { 38 | updateEntity.setUserRole(entity.getUserRole()); 39 | } 40 | return entityManager.merge(updateEntity); 41 | } else { 42 | return null; 43 | } 44 | } catch (Exception e) { 45 | return null; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/domain/AtupTestCase.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.domain; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.util.JaxbDateSerializer; 4 | 5 | import javax.persistence.*; 6 | import javax.xml.bind.annotation.XmlAttribute; 7 | import javax.xml.bind.annotation.XmlElement; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * ATUP Test Case Entity 15 | * 16 | * @author feuyeux@gmail.com 17 | * @since 1.0 18 | * 09/09/2013 19 | */ 20 | @Entity 21 | @Table(name = "test_case") 22 | @XmlRootElement 23 | @NamedQueries({@NamedQuery(name = "findByStatus", query = "SELECT testCase FROM AtupTestCase testCase WHERE testCase.caseStatus= :caseStatus"), 24 | @NamedQuery(name = "findByName", query = "SELECT testCase FROM AtupTestCase testCase WHERE testCase.caseName= :caseName")}) 25 | public class AtupTestCase implements Serializable { 26 | private static final long serialVersionUID = 1L; 27 | private Integer caseId; 28 | private String caseName; 29 | private AtupTestSuite suite; 30 | private String caseBody; 31 | private Date createTime; 32 | private Date updateTime; 33 | private Integer caseStatus; 34 | 35 | public AtupTestCase() { 36 | } 37 | 38 | public AtupTestCase(final String caseName, final AtupTestSuite suite, final String caseBody, final Date createTime, final Date updateTime, 39 | final Integer caseStatus) { 40 | this.caseName = caseName; 41 | this.suite = suite; 42 | this.caseBody = caseBody; 43 | this.createTime = createTime; 44 | this.updateTime = updateTime; 45 | this.caseStatus = caseStatus; 46 | } 47 | 48 | @Id 49 | @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "EMP_SEQ") 50 | @SequenceGenerator(name = "EMP_SEQ") 51 | @Column(unique = true, nullable = false, name = "case_id") 52 | @XmlAttribute 53 | public Integer getCaseId() { 54 | return caseId; 55 | } 56 | 57 | public void setCaseId(final Integer caseId) { 58 | this.caseId = caseId; 59 | } 60 | 61 | @Column(name = "case_name", unique = true) 62 | @XmlAttribute 63 | public String getCaseName() { 64 | return caseName; 65 | } 66 | 67 | public void setCaseName(final String caseName) { 68 | this.caseName = caseName; 69 | } 70 | 71 | @ManyToOne(cascade = CascadeType.REFRESH) 72 | @JoinColumn(name = "suiteId") 73 | @XmlElement 74 | public AtupTestSuite getSuite() { 75 | return suite; 76 | } 77 | 78 | public void setSuite(final AtupTestSuite suite) { 79 | this.suite = suite; 80 | } 81 | 82 | @Column(name = "case_body") 83 | @XmlAttribute 84 | public String getCaseBody() { 85 | return caseBody; 86 | } 87 | 88 | public void setCaseBody(final String caseBody) { 89 | this.caseBody = caseBody; 90 | } 91 | 92 | @Column(name = "create_time") 93 | @XmlAttribute 94 | @XmlJavaTypeAdapter(JaxbDateSerializer.class) 95 | @Temporal(TemporalType.TIMESTAMP) 96 | public Date getCreateTime() { 97 | return createTime; 98 | } 99 | 100 | public void setCreateTime(final Date createTime) { 101 | this.createTime = createTime; 102 | } 103 | 104 | @Column(name = "update_time") 105 | @XmlAttribute 106 | @XmlJavaTypeAdapter(JaxbDateSerializer.class) 107 | @Temporal(TemporalType.TIMESTAMP) 108 | public Date getUpdateTime() { 109 | return updateTime; 110 | } 111 | 112 | public void setUpdateTime(final Date updateTime) { 113 | this.updateTime = updateTime; 114 | } 115 | 116 | @Column(name = "case_status") 117 | @XmlAttribute 118 | public Integer getCaseStatus() { 119 | return caseStatus; 120 | } 121 | 122 | public void setCaseStatus(final Integer caseStatus) { 123 | this.caseStatus = caseStatus; 124 | } 125 | 126 | @Override 127 | public String toString() { 128 | StringBuilder builder = new StringBuilder("AtupTestCase["); 129 | if (caseId != null) { 130 | builder.append("caseId=").append(caseId); 131 | } else { 132 | builder.append("caseId=nil"); 133 | } 134 | if (caseName != null && !caseName.isEmpty()) { 135 | builder.append(",caseName=").append(caseName); 136 | } else { 137 | builder.append(",caseName=nil"); 138 | } 139 | if (suite != null) { 140 | builder.append(",suite=").append(suite); 141 | } else { 142 | builder.append(",suite=nil"); 143 | } 144 | if (caseBody != null && !caseBody.isEmpty()) { 145 | builder.append(",caseBody=").append(caseBody); 146 | } else { 147 | builder.append(",caseBody=nil"); 148 | } 149 | if (caseStatus != null) { 150 | builder.append(",caseStatus=").append(caseStatus); 151 | } else { 152 | builder.append(",caseStatus=nil"); 153 | } 154 | return builder.append("]").toString(); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/domain/AtupTestResult.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.domain; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.util.JaxbDateSerializer; 4 | 5 | import javax.persistence.*; 6 | import javax.xml.bind.annotation.XmlAttribute; 7 | import javax.xml.bind.annotation.XmlElement; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * ATUP Test Result Entity 15 | * 16 | * @author feuyeux@gmail.com 17 | * @since 1.0 18 | * 09/09/2013 19 | */ 20 | @Entity 21 | @Table(name = "test_result") 22 | @XmlRootElement 23 | @NamedQueries({@NamedQuery(name = "findResultByTestCase", query = "SELECT testResult FROM AtupTestResult testResult WHERE testResult.testCase= :testCase"), 24 | @NamedQuery(name = "findResultByStatus", query = "SELECT testResult FROM AtupTestResult testResult WHERE testResult.resultStatus= :resultStatus"), 25 | @NamedQuery(name = "findResultByUser", query = "SELECT testResult FROM AtupTestResult testResult WHERE testResult.user.userId= :userId")}) 26 | public class AtupTestResult implements Serializable { 27 | private static final long serialVersionUID = 1L; 28 | private Integer resultId; 29 | private AtupTestCase testCase; 30 | private AtupUser user; 31 | private Integer resultStatus; 32 | private String resultBody; 33 | private AtupDevice device; 34 | private Date createTime; 35 | private Date updateTime; 36 | 37 | public AtupTestResult() { 38 | } 39 | 40 | public AtupTestResult(final AtupTestCase testCase, final Integer resultStatus, final String resultBody, final Date createTime, 41 | final Date updateTime) { 42 | this.testCase = testCase; 43 | this.resultStatus = resultStatus; 44 | this.resultBody = resultBody; 45 | this.createTime = createTime; 46 | this.updateTime = updateTime; 47 | } 48 | 49 | public AtupTestResult(final AtupTestCase testCase, final AtupUser user, final AtupDevice device, final Integer resultStatus, final String resultBody, final Date createTime, 50 | final Date updateTime) { 51 | this.testCase = testCase; 52 | this.user = user; 53 | this.device = device; 54 | this.resultStatus = resultStatus; 55 | this.resultBody = resultBody; 56 | this.createTime = createTime; 57 | this.updateTime = updateTime; 58 | } 59 | 60 | @Id 61 | @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "EMP_SEQ") 62 | @SequenceGenerator(name = "EMP_SEQ") 63 | @Column(unique = true, nullable = false, name = "result_id") 64 | @XmlAttribute 65 | public Integer getResultId() { 66 | return resultId; 67 | } 68 | 69 | public void setResultId(final Integer resultId) { 70 | this.resultId = resultId; 71 | } 72 | 73 | @ManyToOne 74 | @JoinColumn(name = "caseId") 75 | @XmlElement 76 | public AtupTestCase getTestCase() { 77 | return testCase; 78 | } 79 | 80 | public void setTestCase(final AtupTestCase testCase) { 81 | this.testCase = testCase; 82 | } 83 | 84 | @ManyToOne 85 | @JoinColumn(name = "userId") 86 | @XmlElement 87 | public AtupUser getUser() { 88 | return user; 89 | } 90 | 91 | public void setUser(final AtupUser user) { 92 | this.user = user; 93 | } 94 | 95 | @Column(name = "result_status") 96 | @XmlAttribute 97 | public Integer getResultStatus() { 98 | return resultStatus; 99 | } 100 | 101 | public void setResultStatus(final Integer resultStatus) { 102 | this.resultStatus = resultStatus; 103 | } 104 | 105 | @Column(name = "result_body") 106 | @XmlAttribute 107 | public String getResultBody() { 108 | return resultBody; 109 | } 110 | 111 | public void setResultBody(final String resultBody) { 112 | this.resultBody = resultBody; 113 | } 114 | 115 | @Column(name = "create_time") 116 | @XmlAttribute 117 | @XmlJavaTypeAdapter(JaxbDateSerializer.class) 118 | @Temporal(TemporalType.TIMESTAMP) 119 | public Date getCreateTime() { 120 | return createTime; 121 | } 122 | 123 | public void setCreateTime(final Date createTime) { 124 | this.createTime = createTime; 125 | } 126 | 127 | @Column(name = "update_time") 128 | @XmlAttribute 129 | @XmlJavaTypeAdapter(JaxbDateSerializer.class) 130 | @Temporal(TemporalType.TIMESTAMP) 131 | public Date getUpdateTime() { 132 | return updateTime; 133 | } 134 | 135 | public void setUpdateTime(final Date updateTime) { 136 | this.updateTime = updateTime; 137 | } 138 | 139 | @ManyToOne 140 | @JoinColumn(name = "deviceId") 141 | @XmlElement 142 | public AtupDevice getDevice() { 143 | return device; 144 | } 145 | 146 | public void setDevice(final AtupDevice device) { 147 | this.device = device; 148 | } 149 | 150 | @Override 151 | public String toString() { 152 | return new StringBuilder().append("AtupTestResult[resultId:").append(resultId == null ? "nil" : resultId.toString()).append(",testCase=") 153 | .append(testCase).append(",user=").append(user).append(",resultStatus=") 154 | .append(resultStatus).append(",resultBody=").append(resultBody).append(",device=") 155 | .append(device).append(",createTime=").append(createTime).append(",updateTime=") 156 | .append(updateTime).append("]").toString(); 157 | } 158 | } -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/domain/AtupTestSuite.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.domain; 2 | 3 | import javax.persistence.*; 4 | import javax.xml.bind.annotation.XmlAttribute; 5 | import javax.xml.bind.annotation.XmlRootElement; 6 | import java.io.Serializable; 7 | 8 | /** 9 | * ATUP Test Suite Entity 10 | * 11 | * @author feuyeux@gmail.com 12 | * @since 1.0 13 | * 09/09/2013 14 | */ 15 | @Entity 16 | @Table(name = "test_suite") 17 | @XmlRootElement 18 | @NamedQueries({@NamedQuery(name = "findBySuiteStatus", query = "SELECT testSuite FROM AtupTestSuite testSuite WHERE testSuite.suiteStatus= :suiteStatus"), 19 | @NamedQuery(name = "findBySuiteName", query = "SELECT testSuite FROM AtupTestSuite testSuite WHERE testSuite.suiteName= :suiteName")}) 20 | public class AtupTestSuite implements Serializable { 21 | private static final long serialVersionUID = 1L; 22 | private Integer suiteId; 23 | private String suiteName; 24 | private Integer suiteType; 25 | private Integer suiteStatus; 26 | 27 | public AtupTestSuite() { 28 | } 29 | 30 | public AtupTestSuite(final String suiteName, final Integer suiteType, final Integer suiteStatus) { 31 | this.suiteName = suiteName; 32 | this.suiteType = suiteType; 33 | this.suiteStatus = suiteStatus; 34 | } 35 | 36 | public AtupTestSuite(final Integer suiteId) { 37 | this.suiteId = suiteId; 38 | } 39 | 40 | @Id 41 | @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "EMP_SEQ") 42 | @SequenceGenerator(name = "EMP_SEQ") 43 | @Column(unique = true, nullable = false, name = "suite_id") 44 | @XmlAttribute 45 | public Integer getSuiteId() { 46 | return suiteId; 47 | } 48 | 49 | public void setSuiteId(final Integer suiteId) { 50 | this.suiteId = suiteId; 51 | } 52 | 53 | @Column(name = "suite_name", unique = true) 54 | @XmlAttribute 55 | public String getSuiteName() { 56 | return suiteName; 57 | } 58 | 59 | public void setSuiteName(final String suiteName) { 60 | this.suiteName = suiteName; 61 | } 62 | 63 | @Column(name = "suite_type") 64 | @XmlAttribute 65 | public Integer getSuiteType() { 66 | return suiteType; 67 | } 68 | 69 | public void setSuiteType(final Integer suiteType) { 70 | this.suiteType = suiteType; 71 | } 72 | 73 | @Column(name = "suite_status") 74 | @XmlAttribute 75 | public Integer getSuiteStatus() { 76 | return suiteStatus; 77 | } 78 | 79 | public void setSuiteStatus(final Integer suiteStatus) { 80 | this.suiteStatus = suiteStatus; 81 | } 82 | 83 | @Override 84 | public String toString() { 85 | return "AtupTestSuite" + suiteId + "::" + this.suiteName + "::" + this.suiteType + "::" + this.suiteStatus + "]"; 86 | } 87 | } -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/domain/AtupUser.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.domain; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.info.AtupUserInfo; 5 | 6 | import javax.persistence.*; 7 | import javax.xml.bind.annotation.XmlAttribute; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | import java.io.Serializable; 10 | 11 | /** 12 | * ATUP User Entity 13 | * 14 | * @author feuyeux@gmail.com 15 | * @since 1.0 16 | * 09/09/2013 17 | */ 18 | @Entity 19 | @Table(name = "atup_user") 20 | @XmlRootElement 21 | @NamedQueries({ 22 | @NamedQuery(name = "findByUserName", query = "SELECT atupUser FROM AtupUser atupUser WHERE atupUser.userName= :userName and atupUser.status=0") 23 | }) 24 | public class AtupUser implements Serializable { 25 | private static final long serialVersionUID = 1L; 26 | private Integer userId; 27 | private String userName; 28 | private String passWord; 29 | private Integer userRole = AtupParam.USER_USER; 30 | private Integer status = 0; 31 | 32 | public AtupUser() { 33 | 34 | } 35 | 36 | public AtupUser(final Integer userId, final Integer userRole, final String userName) { 37 | this.userId = userId; 38 | this.userRole = userRole; 39 | this.userName = userName; 40 | } 41 | 42 | public AtupUser(final Integer userRole, final String userName, final String passWord) { 43 | this.userRole = userRole; 44 | this.userName = userName; 45 | this.passWord = passWord; 46 | } 47 | 48 | public AtupUser(final AtupUserInfo userInfo) { 49 | userId = userInfo.getUserId(); 50 | userRole = userInfo.getUserRole(); 51 | userName = userInfo.getUserName(); 52 | passWord = userInfo.getPassWord(); 53 | status = userInfo.getStatus(); 54 | } 55 | 56 | @Id 57 | @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "EMP_SEQ") 58 | @SequenceGenerator(name = "EMP_SEQ") 59 | @Column(unique = true, nullable = false, name = "user_id") 60 | @XmlAttribute 61 | public Integer getUserId() { 62 | return userId; 63 | } 64 | 65 | public void setUserId(final Integer userId) { 66 | this.userId = userId; 67 | } 68 | 69 | @Column(name = "user_role") 70 | @XmlAttribute 71 | public Integer getUserRole() { 72 | return userRole; 73 | } 74 | 75 | public void setUserRole(final Integer userRole) { 76 | this.userRole = userRole; 77 | } 78 | 79 | @Column(name = "user_name", unique = true) 80 | @XmlAttribute 81 | public String getUserName() { 82 | return userName; 83 | } 84 | 85 | public void setUserName(final String userName) { 86 | this.userName = userName; 87 | } 88 | 89 | @Column(name = "user_pwd") 90 | @XmlAttribute 91 | public String getPassWord() { 92 | return passWord; 93 | } 94 | 95 | public void setPassWord(final String passWord) { 96 | this.passWord = passWord; 97 | } 98 | 99 | @Column(name = "user_status") 100 | @XmlAttribute 101 | public Integer getStatus() { 102 | return status; 103 | } 104 | 105 | public void setStatus(Integer status) { 106 | this.status = status; 107 | } 108 | } -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/fake/CreatTestSuite.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.fake; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 5 | 6 | public class CreatTestSuite { 7 | public static final String SUITE_NAME = "FUNCTION TEST"; 8 | public static AtupTestSuite one; 9 | public static AtupTestSuite other; 10 | 11 | public static AtupTestSuite buildTestSuite() { 12 | return new AtupTestSuite(CreatTestSuite.SUITE_NAME + System.nanoTime(), AtupParam.NORMAL_SUITE, AtupParam.NORMAL_CASE); 13 | } 14 | 15 | public static AtupTestSuite buildOneTestSuite() { 16 | if (one == null) { 17 | one = new AtupTestSuite(CreatTestSuite.SUITE_NAME + System.nanoTime(), AtupParam.NORMAL_SUITE, AtupParam.NORMAL_CASE); 18 | } 19 | return one; 20 | } 21 | 22 | public static AtupTestSuite buildOneTestSuite(String suiteName) { 23 | if (other == null) { 24 | other = new AtupTestSuite(suiteName, AtupParam.NORMAL_SUITE, AtupParam.NORMAL_CASE); 25 | } 26 | return other; 27 | } 28 | 29 | public static void removeOne() { 30 | one = null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/fake/CreateDevice.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.fake; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupDevice; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 6 | 7 | import java.util.Date; 8 | 9 | class CreateDevice { 10 | public static AtupDevice buildAtupDevice() { 11 | final AtupUser user = CreateUser.buildUser(); 12 | final String deviceHost = "10.12.13.14"; 13 | final String deviceName = "Test Station"; 14 | final Integer deviceStatus = AtupParam.DEVICE_IDLE; 15 | final Integer deviceType = AtupParam.DEVICE_QUALITY; 16 | final Date createTime = new Date(); 17 | final Date updateTime = new Date(); 18 | return new AtupDevice(user, deviceHost, deviceName, deviceStatus, deviceType, createTime, updateTime); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/fake/CreateTestCase.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.fake; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 6 | 7 | import java.util.Date; 8 | 9 | public class CreateTestCase { 10 | public static AtupTestCase one; 11 | public static final String CASE_NAME = "Test case name_"; 12 | private static final String CASE_BODY = "Test case body"; 13 | 14 | public static AtupTestCase buildTestCase(final AtupTestSuite suite, final String caseName) { 15 | final String caseBody = CreateTestCase.CASE_BODY; 16 | final Date createTime = new Date(); 17 | final Date updateTime = new Date(); 18 | final Integer caseStatus = AtupParam.NORMAL_CASE; 19 | return new AtupTestCase(caseName, suite, caseBody, createTime, updateTime, caseStatus); 20 | } 21 | 22 | public static AtupTestCase buildOneTestCase(final AtupTestSuite suite, final String caseName) { 23 | if (one == null) { 24 | final String caseBody = CreateTestCase.CASE_BODY; 25 | final Date createTime = new Date(); 26 | final Date updateTime = new Date(); 27 | final Integer caseStatus = AtupParam.NORMAL_CASE; 28 | one = new AtupTestCase(caseName, suite, caseBody, createTime, updateTime, caseStatus); 29 | } 30 | return one; 31 | } 32 | 33 | public static AtupTestCase buildTestCase(final AtupTestSuite suite) { 34 | return buildTestCase(suite, CreateTestCase.CASE_NAME); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/fake/CreateTestResult.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.fake; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 6 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 7 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 8 | 9 | import java.util.Date; 10 | 11 | public class CreateTestResult { 12 | private static final String CASE_RESULT_BODY = "Test case body"; 13 | 14 | public static AtupTestResult buildTestResult(final AtupTestCase testCase, final AtupUser user) { 15 | final Integer resultStatus = AtupParam.RESULT_SUCCESS; 16 | final String resultBody = CreateTestResult.CASE_RESULT_BODY; 17 | final Date createTime = new Date(); 18 | final Date updateTime = new Date(); 19 | return new AtupTestResult(testCase, user, null, resultStatus, resultBody, createTime, updateTime); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/fake/CreateUser.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.fake; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 4 | import org.feuyeux.jaxrs2.atup.core.info.AtupUserInfo; 5 | 6 | public class CreateUser { 7 | 8 | private static final String TEST_NAME = "eric"; 9 | public static final String TEST_NAME1 = "mars"; 10 | 11 | public static AtupUserInfo buildUserInfo() { 12 | final AtupUser user = buildUser(); 13 | return new AtupUserInfo(user); 14 | } 15 | 16 | public static AtupUser buildUser() { 17 | final Integer userRole = 1; 18 | final String userName = CreateUser.TEST_NAME + System.nanoTime(); 19 | final String passWord = "han"; 20 | return new AtupUser(userRole, userName, passWord); 21 | } 22 | } -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupDeviceListInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupDevice; 4 | 5 | import java.util.List; 6 | 7 | public class AtupDeviceListInfo extends AtupInfo { 8 | private static final long serialVersionUID = 1L; 9 | private List deviceList; 10 | 11 | public AtupDeviceListInfo(final List deviceList) { 12 | this.deviceList = deviceList; 13 | } 14 | 15 | public AtupDeviceListInfo() { 16 | } 17 | 18 | public List getDeviceList() { 19 | return deviceList; 20 | } 21 | 22 | public void setDeviceList(final List deviceList) { 23 | this.deviceList = deviceList; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupErrorCode.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | public interface AtupErrorCode { 4 | int NONE = 9200; 5 | int INVALID_PARAM = 9400; 6 | int UNAUTHORIZED_ERROR = 9401; 7 | int FORBIDDEN_ERROR = 9403; 8 | int PERSIST_ERROR = 9500; 9 | } 10 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupErrorInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | public interface AtupErrorInfo { 4 | String INVALID_PARAM = "invalid parameters"; 5 | } 6 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import javax.xml.bind.annotation.XmlAttribute; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | import java.io.Serializable; 6 | 7 | /** 8 | * ATUP Device Info 9 | * 10 | * @author feuyeux@gmail.com 11 | * @since 1.0 12 | * 09/09/2013 13 | */ 14 | @XmlRootElement 15 | public abstract class AtupInfo implements Serializable { 16 | private static final long serialVersionUID = 1L; 17 | private String errorInfo; 18 | private Integer statusCode = AtupErrorCode.NONE; 19 | 20 | AtupInfo() { 21 | } 22 | 23 | AtupInfo(final String errorInfo, final Integer statusCode) { 24 | this.errorInfo = errorInfo; 25 | this.statusCode = statusCode; 26 | } 27 | 28 | @XmlAttribute 29 | public String getErrorInfo() { 30 | return errorInfo; 31 | } 32 | 33 | public void setErrorInfo(final String errorInfo) { 34 | this.errorInfo = errorInfo; 35 | } 36 | 37 | @XmlAttribute 38 | public Integer getStatusCode() { 39 | return statusCode; 40 | } 41 | 42 | public void setStatusCode(final Integer statusCode) { 43 | this.statusCode = statusCode; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupTestCaseListInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 4 | 5 | import javax.xml.bind.annotation.XmlElement; 6 | import java.util.List; 7 | 8 | public class AtupTestCaseListInfo extends AtupInfo { 9 | private static final long serialVersionUID = 1L; 10 | private List testCaseList; 11 | 12 | public AtupTestCaseListInfo(final List testCaseList) { 13 | this.testCaseList = testCaseList; 14 | } 15 | 16 | public AtupTestCaseListInfo() { 17 | } 18 | 19 | public AtupTestCaseListInfo(final String errorInfo, final Integer statusCode) { 20 | super(errorInfo, statusCode); 21 | } 22 | 23 | @XmlElement 24 | public List getTestCaseList() { 25 | return testCaseList; 26 | } 27 | 28 | public void setTestCaseList(final List testCaseList) { 29 | this.testCaseList = testCaseList; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupTestJobInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import javax.xml.bind.annotation.XmlAttribute; 4 | import javax.xml.bind.annotation.XmlRootElement; 5 | 6 | /** 7 | * ATUP Test Job Info 8 | * 9 | * @author feuyeux@gmail.com 10 | * @since 1.0 11 | * 09/09/2013 12 | */ 13 | 14 | @XmlRootElement 15 | public class AtupTestJobInfo extends AtupInfo implements Comparable { 16 | private Integer jobId; 17 | private Integer userId; 18 | private String deviceIp; 19 | private Integer caseId; 20 | private Integer priority; 21 | private Long generatedTime; 22 | 23 | public AtupTestJobInfo() { 24 | 25 | } 26 | 27 | public AtupTestJobInfo(Integer userId, String deviceIp, Integer caseId, Integer priority, Long generatedTime) { 28 | this.userId = userId; 29 | this.deviceIp = deviceIp; 30 | this.caseId = caseId; 31 | this.priority = priority; 32 | this.generatedTime = generatedTime; 33 | } 34 | 35 | @XmlAttribute 36 | public Integer getJobId() { 37 | return jobId; 38 | } 39 | 40 | public void setJobId(final Integer jobId) { 41 | this.jobId = jobId; 42 | } 43 | 44 | @XmlAttribute 45 | public Integer getUserId() { 46 | return userId; 47 | } 48 | 49 | public void setUserId(final Integer userId) { 50 | this.userId = userId; 51 | } 52 | 53 | @XmlAttribute 54 | public Integer getCaseId() { 55 | return caseId; 56 | } 57 | 58 | public void setCaseId(final Integer caseId) { 59 | this.caseId = caseId; 60 | } 61 | 62 | @XmlAttribute 63 | public Integer getPriority() { 64 | return priority; 65 | } 66 | 67 | public void setPriority(final Integer priority) { 68 | this.priority = priority; 69 | } 70 | 71 | @XmlAttribute 72 | public String getDeviceIp() { 73 | return deviceIp; 74 | } 75 | 76 | public void setDeviceIp(final String deviceIp) { 77 | this.deviceIp = deviceIp; 78 | } 79 | 80 | @XmlAttribute 81 | public Long getGeneratedTime() { 82 | return generatedTime; 83 | } 84 | 85 | public void setGeneratedTime(Long generatedTime) { 86 | this.generatedTime = generatedTime; 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return "job[" + jobId + "] priority:" + priority + ",generatedTime:" + generatedTime + ",userId=" + userId + ",deviceIp=" + deviceIp + ",caseId=" + caseId; 92 | } 93 | 94 | @Override 95 | public boolean equals(Object obj) { 96 | if (obj == null) { 97 | return false; 98 | } 99 | 100 | if (obj == this) { 101 | return true; 102 | } 103 | 104 | if (obj.getClass().equals(AtupTestJobInfo.class)) { 105 | AtupTestJobInfo other = (AtupTestJobInfo) obj; 106 | return other.deviceIp.equals(this.deviceIp) && other.userId.equals(this.userId) && other.caseId.equals(this.caseId); 107 | } 108 | return false; 109 | } 110 | 111 | @Override 112 | public int hashCode() { 113 | return jobId.hashCode() + userId.hashCode(); 114 | } 115 | 116 | @Override 117 | public int compareTo(AtupTestJobInfo other) { 118 | int result = this.priority.compareTo(other.priority); 119 | if (result == 0) { 120 | return this.generatedTime.compareTo(other.generatedTime); 121 | } else { 122 | return result; 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupTestJobListInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import java.util.List; 4 | 5 | public class AtupTestJobListInfo extends AtupInfo { 6 | private static final long serialVersionUID = 1L; 7 | private List jobs; 8 | 9 | public AtupTestJobListInfo() { 10 | } 11 | 12 | public AtupTestJobListInfo(final List jobs) { 13 | this.jobs = jobs; 14 | } 15 | 16 | public List getJobs() { 17 | return jobs; 18 | } 19 | 20 | public void setJobs(List jobs) { 21 | this.jobs = jobs; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupTestResultListInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 4 | 5 | import java.util.List; 6 | 7 | public class AtupTestResultListInfo extends AtupInfo { 8 | private static final long serialVersionUID = 1L; 9 | private List resultList; 10 | 11 | public AtupTestResultListInfo() { 12 | } 13 | 14 | public AtupTestResultListInfo(final List resultList) { 15 | this.resultList = resultList; 16 | } 17 | 18 | public AtupTestResultListInfo(final String errorInfo, final Integer statusCode) { 19 | super(errorInfo, statusCode); 20 | } 21 | 22 | public List getResultList() { 23 | return resultList; 24 | } 25 | 26 | public void setResultList(final List resultList) { 27 | this.resultList = resultList; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupTestSuiteInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite; 4 | 5 | public class AtupTestSuiteInfo extends AtupInfo { 6 | private static final long serialVersionUID = 1L; 7 | private Integer suiteId; 8 | private String suiteName; 9 | private Integer suiteType; 10 | private Integer suiteStatus; 11 | 12 | public AtupTestSuiteInfo(final AtupTestSuite testSuite) { 13 | suiteId = testSuite.getSuiteId(); 14 | suiteName = testSuite.getSuiteName(); 15 | suiteStatus = testSuite.getSuiteStatus(); 16 | suiteType = testSuite.getSuiteType(); 17 | } 18 | 19 | public AtupTestSuiteInfo() { 20 | } 21 | 22 | public Integer getSuiteId() { 23 | return suiteId; 24 | } 25 | 26 | public void setSuiteId(final Integer suiteId) { 27 | this.suiteId = suiteId; 28 | } 29 | 30 | public String getSuiteName() { 31 | return suiteName; 32 | } 33 | 34 | public void setSuiteName(final String suiteName) { 35 | this.suiteName = suiteName; 36 | } 37 | 38 | public Integer getSuiteType() { 39 | return suiteType; 40 | } 41 | 42 | public void setSuiteType(final Integer suiteType) { 43 | this.suiteType = suiteType; 44 | } 45 | 46 | public Integer getSuiteStatus() { 47 | return suiteStatus; 48 | } 49 | 50 | public void setSuiteStatus(final Integer suiteStatus) { 51 | this.suiteStatus = suiteStatus; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupTestSuiteListInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import java.util.List; 4 | 5 | public class AtupTestSuiteListInfo extends AtupInfo { 6 | private static final long serialVersionUID = 1L; 7 | 8 | private List suiteList; 9 | 10 | public AtupTestSuiteListInfo() { 11 | } 12 | 13 | public AtupTestSuiteListInfo(final String errorInfo, final Integer statusCode) { 14 | super(errorInfo, statusCode); 15 | } 16 | 17 | public List getSuiteList() { 18 | return suiteList; 19 | } 20 | 21 | public void setSuiteList(final List suiteList) { 22 | this.suiteList = suiteList; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupUserInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 4 | 5 | import javax.xml.bind.annotation.XmlAttribute; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * ATUP Device Info 10 | * 11 | * @author feuyeux@gmail.com 12 | * @since 1.0 13 | * 09/09/2013 14 | */ 15 | @XmlRootElement 16 | public class AtupUserInfo extends AtupInfo { 17 | private static final long serialVersionUID = 1L; 18 | private Integer userId; 19 | private Integer userRole; 20 | private String userName; 21 | private String passWord; 22 | private Integer status; 23 | 24 | public AtupUserInfo() { 25 | } 26 | 27 | public AtupUserInfo(final Integer userId) { 28 | this.userId = userId; 29 | } 30 | 31 | public AtupUserInfo(final Integer userRole, final String userName, final String passWord) { 32 | this.userRole = userRole; 33 | this.userName = userName; 34 | this.passWord = passWord; 35 | } 36 | 37 | public AtupUserInfo(final AtupUser userDomain) { 38 | userId = userDomain.getUserId(); 39 | userName = userDomain.getUserName(); 40 | passWord = userDomain.getPassWord(); 41 | userRole = userDomain.getUserRole(); 42 | status = userDomain.getStatus(); 43 | } 44 | 45 | public AtupUserInfo(final String errorInfo, final Integer statusCode) { 46 | super(errorInfo, statusCode); 47 | } 48 | 49 | @XmlAttribute 50 | public Integer getUserId() { 51 | return userId; 52 | } 53 | 54 | public void setUserId(final Integer userId) { 55 | this.userId = userId; 56 | } 57 | 58 | @XmlAttribute 59 | public Integer getUserRole() { 60 | return userRole; 61 | } 62 | 63 | public void setUserRole(final Integer userRole) { 64 | this.userRole = userRole; 65 | } 66 | 67 | @XmlAttribute 68 | public String getUserName() { 69 | return userName; 70 | } 71 | 72 | public void setUserName(final String userName) { 73 | this.userName = userName; 74 | } 75 | 76 | @XmlAttribute 77 | public String getPassWord() { 78 | return passWord; 79 | } 80 | 81 | public void setPassWord(final String passWord) { 82 | this.passWord = passWord; 83 | } 84 | 85 | public Integer getStatus() { 86 | return status; 87 | } 88 | 89 | public void setStatus(Integer status) { 90 | this.status = status; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/info/AtupUserListInfo.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.info; 2 | 3 | import java.util.List; 4 | 5 | public class AtupUserListInfo extends AtupInfo { 6 | private static final long serialVersionUID = 1L; 7 | 8 | private List userList; 9 | 10 | public AtupUserListInfo() { 11 | } 12 | 13 | public AtupUserListInfo(final List userList) { 14 | this.userList = userList; 15 | } 16 | 17 | public List getUserList() { 18 | return userList; 19 | } 20 | 21 | public void setUserList(final List userList) { 22 | this.userList = userList; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/rest/AtupRequestParam.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.rest; 2 | 3 | class AtupRequestParam { 4 | private String key; 5 | private Object value; 6 | 7 | public AtupRequestParam(final String key, final Object value) { 8 | super(); 9 | this.key = key; 10 | this.value = value; 11 | } 12 | 13 | public String getKey() { 14 | return key; 15 | } 16 | 17 | public void setKey(final String key) { 18 | this.key = key; 19 | } 20 | 21 | public Object getValue() { 22 | return value; 23 | } 24 | 25 | public void setValue(final Object value) { 26 | this.value = value; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/util/AtupCrossDomainFilter.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.util; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | 6 | import javax.ws.rs.container.ContainerRequestContext; 7 | import javax.ws.rs.container.ContainerRequestFilter; 8 | import javax.ws.rs.container.ContainerResponseContext; 9 | import javax.ws.rs.container.ContainerResponseFilter; 10 | import javax.ws.rs.ext.Provider; 11 | import java.io.IOException; 12 | 13 | @Provider 14 | public class AtupCrossDomainFilter implements ContainerRequestFilter, ContainerResponseFilter { 15 | private final Logger log = LogManager.getLogger(AtupCrossDomainFilter.class.getName()); 16 | 17 | @Override 18 | public void filter(final ContainerRequestContext requestContext) throws IOException { 19 | log.debug(requestContext.getHeaders().getFirst("Access-Control-Allow-Origin")); 20 | } 21 | 22 | @Override 23 | public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext) throws IOException { 24 | responseContext.getHeaders().add("Access-Control-Allow-Origin", "*"); 25 | responseContext.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization, Atup-User, Atup-UserRole"); 26 | responseContext.getHeaders().add("Access-Control-Allow-Credentials", "true"); 27 | responseContext.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD"); 28 | responseContext.getHeaders().add("Access-Control-Max-Age", "1209600"); 29 | } 30 | } -------------------------------------------------------------------------------- /atup-core/src/main/java/org/feuyeux/jaxrs2/atup/core/util/JaxbDateSerializer.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.core.util; 2 | 3 | import javax.xml.bind.annotation.adapters.XmlAdapter; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | public class JaxbDateSerializer extends XmlAdapter { 8 | private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); 9 | 10 | @Override 11 | public String marshal(final Date date) throws Exception { 12 | if (date == null) { 13 | return ""; 14 | } else { 15 | return dateFormat.format(date); 16 | } 17 | } 18 | 19 | @Override 20 | public Date unmarshal(final String date) throws Exception { 21 | if (date == null || date.isEmpty()) { 22 | return null; 23 | } else { 24 | return dateFormat.parse(date); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /atup-device/mvn-eclipse.bat: -------------------------------------------------------------------------------- 1 | cd %1 2 | call mvn eclipse:clean && mvn -Dwtp.version=3.5.1 eclipse:eclipse -------------------------------------------------------------------------------- /atup-device/mvn-eclipse.sh: -------------------------------------------------------------------------------- 1 | cd $1 2 | mvn -Dwtp.version=3.5.1 eclipse:clean eclipse:eclipse 3 | mvn clean install -Dmaven.test.skip=true 4 | mvn dependency:sources 5 | -------------------------------------------------------------------------------- /atup-device/readme.md: -------------------------------------------------------------------------------- 1 | /*Device */ 2 | Integer DEVICE_IDLE = 0; 3 | Integer DEVICE_RUNNING = 1; 4 | Integer DEVICE_ERROR = 2; 5 | 6 | var DEVICE_STATUS_IDLE="0"; 7 | var DEVICE_STATUS_BUSY="1"; 8 | var DEVICE_STATUS_ERROR="2"; -------------------------------------------------------------------------------- /atup-device/src/main/java/org/feuyeux/jaxrs2/atup/device/AtupDeviceApplication.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.device; 2 | 3 | import org.glassfish.jersey.server.ResourceConfig; 4 | 5 | import javax.ws.rs.ApplicationPath; 6 | 7 | @ApplicationPath("/rest-api/*") 8 | class AtupDeviceApplication extends ResourceConfig { 9 | public AtupDeviceApplication() { 10 | register(org.feuyeux.jaxrs2.atup.device.resource.AtupDeviceResource.class); 11 | register(org.feuyeux.jaxrs2.atup.core.util.AtupCrossDomainFilter.class); 12 | } 13 | } -------------------------------------------------------------------------------- /atup-device/src/main/java/org/feuyeux/jaxrs2/atup/device/resource/AtupDeviceResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.device.resource; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 6 | import org.feuyeux.jaxrs2.atup.core.domain.AtupDevice; 7 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 8 | import org.feuyeux.jaxrs2.atup.core.info.AtupDeviceListInfo; 9 | import org.feuyeux.jaxrs2.atup.device.service.AtupDeviceService; 10 | import org.feuyeux.jaxrs2.atup.device.service.StationDetectService; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | 14 | import javax.ws.rs.*; 15 | import javax.ws.rs.core.Context; 16 | import javax.ws.rs.core.HttpHeaders; 17 | import javax.ws.rs.core.MediaType; 18 | import java.util.List; 19 | import java.util.concurrent.ExecutionException; 20 | 21 | @Component 22 | @Path(AtupApi.DEVICE_PATH) 23 | public class AtupDeviceResource { 24 | private final Logger log = LogManager.getLogger(AtupDeviceResource.class.getName()); 25 | @Autowired 26 | private AtupDeviceService service; 27 | @Autowired 28 | private StationDetectService detectService; 29 | 30 | @PUT 31 | @Produces(MediaType.APPLICATION_JSON) 32 | @Consumes(MediaType.APPLICATION_JSON) 33 | public AtupDevice updateDevice(@Context final HttpHeaders headers, final AtupDevice deviceInfo) { 34 | try { 35 | if (deviceInfo.getUser() == null) { 36 | fillUser(headers, deviceInfo); 37 | } 38 | return service.updateDevice(deviceInfo); 39 | } catch (final Exception e) { 40 | log.error(e); 41 | return null; 42 | } 43 | } 44 | 45 | private void fillUser(final HttpHeaders headers, final AtupDevice deviceInfo) { 46 | final String userId = headers.getRequestHeader("Atup-User").get(0); 47 | final AtupUser currentUser = new AtupUser(); 48 | currentUser.setUserId(Integer.valueOf(userId)); 49 | deviceInfo.setUser(currentUser); 50 | } 51 | 52 | @GET 53 | @Produces(MediaType.APPLICATION_JSON) 54 | public AtupDeviceListInfo getDevicesByUser(@Context final HttpHeaders headers) { 55 | final String userId = headers.getRequestHeader("Atup-User").get(0); 56 | final List devices = service.getDeviceList(Integer.valueOf(userId)); 57 | return new AtupDeviceListInfo(devices); 58 | } 59 | 60 | @GET 61 | @Path("all") 62 | @Produces(MediaType.APPLICATION_JSON) 63 | public AtupDeviceListInfo getDevices() { 64 | final List devices = service.getDeviceList(); 65 | return new AtupDeviceListInfo(devices); 66 | } 67 | 68 | @POST 69 | @Produces(MediaType.APPLICATION_JSON) 70 | @Consumes(MediaType.APPLICATION_JSON) 71 | public AtupDevice createDevice(@Context final HttpHeaders headers, final AtupDevice deviceInfo) { 72 | try { 73 | fillUser(headers, deviceInfo); 74 | return service.createDevice(deviceInfo); 75 | } catch (final Exception e) { 76 | log.error(e); 77 | return null; 78 | } 79 | } 80 | 81 | @POST 82 | @Path("status") 83 | public void detect() throws ExecutionException, InterruptedException { 84 | detectService.detect(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /atup-device/src/main/java/org/feuyeux/jaxrs2/atup/device/service/AtupDeviceService.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.device.service; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.dao.AtupDeviceDao; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupDevice; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Calendar; 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | @Service 13 | public class AtupDeviceService { 14 | @Autowired 15 | AtupDeviceDao dao; 16 | 17 | public AtupDevice createDevice(final AtupDevice device) { 18 | final Date now = Calendar.getInstance().getTime(); 19 | device.setCreateTime(now); 20 | device.setUpdateTime(now); 21 | return dao.save(device); 22 | } 23 | 24 | public AtupDevice updateDevice(final AtupDevice device) { 25 | final Date now = Calendar.getInstance().getTime(); 26 | device.setUpdateTime(now); 27 | return dao.update(device); 28 | } 29 | 30 | public List getDeviceList(final Integer userId) { 31 | return dao.findDevicesByUser(userId); 32 | } 33 | 34 | public List getDeviceList() { 35 | return dao.findAll(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /atup-device/src/main/java/org/feuyeux/jaxrs2/atup/device/service/StationDetectService.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.device.service; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 4 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 5 | import org.feuyeux.jaxrs2.atup.core.constant.AtupVariable; 6 | import org.feuyeux.jaxrs2.atup.core.dao.AtupDeviceDao; 7 | import org.feuyeux.jaxrs2.atup.core.domain.AtupDevice; 8 | import org.feuyeux.jaxrs2.atup.core.rest.AtupRequest; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | import java.util.concurrent.ScheduledExecutorService; 14 | import java.util.concurrent.ScheduledThreadPoolExecutor; 15 | import java.util.concurrent.TimeUnit; 16 | 17 | @Service 18 | public class StationDetectService { 19 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(StationDetectService.class.getName()); 20 | @Autowired 21 | AtupDeviceDao dao; 22 | private final ScheduledExecutorService detectTask = new ScheduledThreadPoolExecutor(1); 23 | 24 | public void detect() { 25 | detectTask.scheduleWithFixedDelay(new Runnable() { 26 | @Override 27 | public void run() { 28 | try { 29 | List deviceList = dao.findAll(); 30 | for (final AtupDevice atupDevice : deviceList) { 31 | String deviceIp = atupDevice.getDeviceHost(); 32 | final String detectPath = AtupApi.PROTOCOL + deviceIp + ":" + AtupApi.SERVICE_PORT + AtupApi.SERVICE_PATH; 33 | log.debug("detectPath= " + detectPath); 34 | final AtupRequest request = new AtupRequest<>(); 35 | request.timeout(AtupVariable.DETECT_CONNECT_TIMEOUT, 0); 36 | try { 37 | final Integer result = request.rest(AtupRequest.GET, detectPath, Integer.class); 38 | log.debug("detecting " + deviceIp + " :" + result); 39 | if (!result.equals(atupDevice.getDeviceStatus())) { 40 | atupDevice.setDeviceStatus(result); 41 | dao.update(atupDevice); 42 | } 43 | } catch (final Exception e) { 44 | log.error(e); 45 | if (!AtupParam.DEVICE_ERROR.equals(atupDevice.getDeviceStatus())) { 46 | atupDevice.setDeviceStatus(AtupParam.DEVICE_ERROR); 47 | dao.update(atupDevice); 48 | } 49 | } 50 | } 51 | } catch (final Exception e) { 52 | log.error(e); 53 | } 54 | } 55 | }, 0, AtupVariable.DETECT_INTERVAL, TimeUnit.SECONDS); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /atup-device/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | org.eclipse.persistence.jpa.PersistenceProvider 9 | java:/comp/env/jdbc/AtupDataSource 10 | java:/comp/env/jdbc/AtupDataSource 11 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 12 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 13 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 14 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 15 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | org.eclipse.persistence.jpa.PersistenceProvider 24 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 25 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 26 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 27 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 28 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /atup-device/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /atup-device/src/main/resources/applicationContext2.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /atup-device/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %p %c{1.} [%t] %m %ex%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /atup-device/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | ATUP Device Management 6 | 7 | Container 8 | jdbc/AtupDataSource 9 | javax.sql.DataSource 10 | 11 | 12 | -------------------------------------------------------------------------------- /atup-device/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

ATUP Device -- A Jersey RESTful Web Application

4 | WADL 5 | 6 | 7 | -------------------------------------------------------------------------------- /atup-device/src/test/java/org/feuyeux/jaxrs2/atup/device/dao/TUDeviceDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.device.dao; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.dao.AtupDeviceDao; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.test.context.ContextConfiguration; 8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 9 | 10 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 11 | @RunWith(SpringJUnit4ClassRunner.class) 12 | public class TUDeviceDao { 13 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(TUDeviceDao.class.getName()); 14 | @Autowired 15 | AtupDeviceDao deviceDao; 16 | 17 | @Test 18 | public void testFindAll() { 19 | log.info(">>Test find all device list"); 20 | deviceDao.findAll(); 21 | log.info("< request = new AtupRequest<>(); 22 | final AtupDevice device = request.rest(AtupRequest.GET, TSDeviceResource.BASE_URI + AtupApi.DEVICE_PATH + "/1", null, null, 23 | MediaType.APPLICATION_JSON_TYPE, AtupDevice.class); 24 | log.info(device); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /atup-page/mvn-eclipse.bat: -------------------------------------------------------------------------------- 1 | cd %1 2 | call mvn eclipse:clean && mvn -Dwtp.version=3.5.1 eclipse:eclipse -------------------------------------------------------------------------------- /atup-page/mvn-eclipse.sh: -------------------------------------------------------------------------------- 1 | cd $1 2 | mvn -Dwtp.version=3.5.1 eclipse:clean eclipse:eclipse 3 | mvn clean install -Dmaven.test.skip=true 4 | mvn dependency:sources 5 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/cases/testCase.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Case Page 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 | 19 |
20 |
Create Test Case
21 | 22 | 24 |
Case Name:
26 |
Case Description:
29 |
30 | 31 |
32 |
33 |
Update Test Case
34 | 35 | 37 |
Case Name:
39 |
Case Description:
42 |
Status:
44 |
45 | 46 |
47 |
48 | Index 49 | 50 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/cases/testCases.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Case List 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 |
20 | Index 21 | 22 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/cases/testResult.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Result Page 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 | 19 |
20 | Index 21 | 22 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/cases/testResults.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Result List 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 | Index 20 | 21 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/cases/testSuite.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Suite Page 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 |
Create Test Suite
20 | 21 |
Test Suite Name: 22 |
23 |
24 | 25 |
26 | 27 |
28 |
Update Test Suite
29 | 30 |
Test Suite Name: 31 |
32 |
Test Suite Status: 33 |
34 |
Test Suite Type: 35 |
36 |
37 | 38 |
39 | 40 |
41 | Test Case 42 | Index 43 | 44 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/cases/testSuites.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Suite List 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 |
20 | Index 21 | 22 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/devices/device.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Device Page 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 |
Create Device
20 | 21 |
22 |
24 |
Device Name: 25 |
26 |
Device Type: 27 |
28 |
29 | 30 |
31 |
32 |
Update Device
33 | 34 |
Device IP: 35 |
36 |
Device Name: 37 |
38 |
Device Type: 39 |
40 |
Device Status: 41 |
42 |
User:
43 |
44 | 45 |
46 | 47 |
48 | Index 49 | 50 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/devices/devices.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Device List 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 | Index 20 | 21 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feuyeux/jax-rs2-atup/b76284e518e641ca16dbe5b4cf7f4e308ad6cede/atup-page/src/main/webapp/favicon.ico -------------------------------------------------------------------------------- /atup-page/src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Atup Index 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 |
21 |
22 |
Devices
23 |
24 | Device List
25 |
26 |
Test Cases
27 | 32 |
Test Jobs/Results
33 |
34 | Job List
35 | Result List
36 |
37 |
38 |
39 | 40 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/jobs/jobsQueue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Job Page 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 | 19 |
20 |
Schedule A Test Job
21 | 22 |
Case Id:
24 |
Case Name:
26 |
Device to run:
27 |
Priority:
28 |
29 | 30 |
31 | 32 |
33 | Job List 34 | Index 35 | 36 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/jobs/runningJobs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Device List 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 | Case List 20 | Index 21 | 22 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/atupCommon_staging.js: -------------------------------------------------------------------------------- 1 | //var ATUP_CASE_HOST = "http://10.11.72.57:8080/"; 2 | //var ATUP_DEVICE_HOST = "http://10.11.72.57:8080/"; 3 | //var ATUP_USER_HOST = "http://10.11.72.57:8080/"; 4 | //var ATUP_PAGE_HOST = "http://10.11.72.57/"; 5 | 6 | var ATUP_CASE_HOST = "http://192.168.1.180:8080/"; 7 | var ATUP_DEVICE_HOST = "http://192.168.1.180:8080/"; 8 | var ATUP_USER_HOST = "http://192.168.1.180:8080/"; 9 | var ATUP_PAGE_HOST = "http://192.168.1.160/"; 10 | 11 | var ATUP_CASE_BASE_URI = 'atup-case/rest-api'; 12 | var ATUP_DEVICE_BASE_URI = 'atup-device/rest-api'; 13 | var ATUP_USER_BASE_URI = 'atup-user/rest-api'; 14 | var ATUP_PAGE_BASE_URI = 'atup-page/'; 15 | 16 | var ATUP_CASE_URI = ATUP_CASE_HOST + ATUP_CASE_BASE_URI; 17 | var ATUP_DEVICE_URI = ATUP_DEVICE_HOST + ATUP_DEVICE_BASE_URI; 18 | var ATUP_USER_URI = ATUP_USER_HOST + ATUP_USER_BASE_URI; 19 | var ATUP_PAGE_URI = ATUP_PAGE_HOST + ATUP_PAGE_BASE_URI; -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/atupRest.js: -------------------------------------------------------------------------------- 1 | var storage = window.sessionStorage; 2 | 3 | var TEST_SUITE_PATH = "/testsuites"; 4 | var TEST_CASE_PATH = "/testcases"; 5 | var TEST_RESULT_PATH = "/testresults"; 6 | var TEST_JOB_PATH = "/testjobs"; 7 | 8 | var USER_PATH = "/users"; 9 | var DEVICE_PATH = "/devices"; 10 | var SIGNIN_PATH = "/users/signin"; 11 | 12 | var NO_RESULT = "There's no result from the server"; 13 | 14 | var GET_METHOD = 'GET'; 15 | var POST_METHOD = 'POST'; 16 | var PUT_METHOD = 'PUT'; 17 | var DELETE_METHOD = 'DELETE'; 18 | 19 | var SPAN_BEGIN = ""; 20 | var SPAN_BEGIN2 = ""; 21 | var SPAN_BEGIN4 = ""; 22 | 23 | var ROLE_ADMIN = 1; 24 | var ROLE_JOB_KILLER = 2; 25 | var ROLE_DEVICE_MANAGER = 3; 26 | var ROLE_USER = 4; 27 | 28 | var DEVICE_STATUS_IDLE = "0"; 29 | var DEVICE_STATUS_BUSY = "1"; 30 | var DEVICE_STATUS_ERROR = "2"; 31 | 32 | var NORMAL_STATUS = 9200; 33 | var LOADING = "Loading..."; 34 | function restGet(restUrl, httpMethod, callback) { 35 | rest(restUrl, httpMethod, "", "application/json", "json", callback); 36 | } 37 | function restSet(restUrl, httpMethod, entity, callback) { 38 | rest(restUrl, httpMethod, entity, "application/json", "json", callback); 39 | } 40 | function rest(restUrl, httpMethod, entity, contentType, dataType, callback) { 41 | var resultLine = jQuery('#resultDiv'); 42 | resultLine.html(LOADING); 43 | var userId = storage.getItem("userId"); 44 | var userRole = storage.getItem("userRole"); 45 | var request = jQuery.ajax({type: httpMethod, url: restUrl, headers: {'Atup-User': userId, 'Atup-UserRole': userRole}, data: entity, contentType: contentType, dataType: dataType, 46 | crossDomain: true});//'Access-Control-Allow-Origin': '*', 47 | request.done(function (data) { 48 | try { 49 | if (data === null || data === undefined) { 50 | resultLine.html(NO_RESULT); 51 | } else if (data.statusCode && data.statusCode != NORMAL_STATUS) { 52 | resultLine.html("Error:" + data.errorInfo); 53 | } else if (callback != null) { 54 | resultLine.html(""); 55 | callback(data); 56 | } 57 | } catch (e) { 58 | resultLine.html(e); 59 | } 60 | }); 61 | request.fail(function (textStatus, errorThrown) { 62 | resultLine.html(errorThrown + " status=" + textStatus.status + " text=" + textStatus.statusText); 63 | }); 64 | resultLine.append(" DONE!"); 65 | } 66 | 67 | function checkSignIn() { 68 | var storageUserId = storage.getItem("userId"); 69 | if (storageUserId == null) { 70 | window.location.href = ATUP_PAGE_URI + "signIn.html"; 71 | } else { 72 | var user = storage.getItem("userName"); 73 | jQuery('#topDiv').html("Welcome " + user); 74 | } 75 | } 76 | function getValue(query, key) { 77 | var vars = query.split("&"); 78 | for (var i = 0; i < vars.length; i++) { 79 | var parts = vars[i].split("="); 80 | if (parts[0] == key) { 81 | return parts[1]; 82 | } 83 | } 84 | return null; 85 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/cases/testCase.js: -------------------------------------------------------------------------------- 1 | function initial() { 2 | checkSignIn(); 3 | restGet(ATUP_CASE_URI + TEST_SUITE_PATH + "/suites?start=0&size=100", GET_METHOD, renderSuiteList0); 4 | jQuery("#caseName").change(function () { 5 | restGet(ATUP_CASE_URI + TEST_SUITE_PATH + "/suites?start=0&size=100", GET_METHOD, renderSuiteList); 6 | var caseName = jQuery("#caseName").val(); 7 | restGet(ATUP_CASE_URI + TEST_CASE_PATH + "/" + caseName, GET_METHOD, fresh4Update); 8 | }); 9 | } 10 | function renderSuites(data) { 11 | var list = data.suiteList; 12 | var html = ""; 13 | jQuery.each(list, function (i, suite) { 14 | html += ""; 17 | }); 18 | return html; 19 | } 20 | function renderSuiteList0(data) { 21 | var html = renderSuites(data); 22 | jQuery("#suiteList0").empty().append(html); 23 | } 24 | function renderSuiteList(data) { 25 | var html = renderSuites(data); 26 | jQuery("#suiteList").empty().append(html); 27 | } 28 | function createCase() { 29 | var suiteId = jQuery("#suiteList0").val(); 30 | var caseName = jQuery("#caseName0").val(); 31 | var caseBody = jQuery("#caseBody0").val(); 32 | var postData = JSON.stringify({caseName: caseName, caseBody: caseBody, caseStatus: 1, suite: {suiteId: suiteId}}); 33 | restSet(ATUP_CASE_URI + TEST_CASE_PATH, POST_METHOD, postData, renderEdit); 34 | } 35 | function updateCase() { 36 | var suiteId = jQuery("#suiteList").val(); 37 | var caseName = jQuery("#caseName").val(); 38 | var caseBody = jQuery("#caseBody").val(); 39 | var caseStatus = jQuery("#caseStatus").val(); 40 | var putData = JSON.stringify({caseName: caseName, caseBody: caseBody, caseStatus: caseStatus, suite: {suiteId: suiteId}}); 41 | restSet( ATUP_CASE_URI + TEST_CASE_PATH, PUT_METHOD, putData, renderEdit); 42 | } 43 | function renderEdit(data) { 44 | var resultDiv = jQuery('#resultDiv'); 45 | resultDiv.html("id=" + data.caseId); 46 | resultDiv.append(" name=" + data.caseName); 47 | resultDiv.append(" status=" + data.caseStatus); 48 | resultDiv.append(" type=" + data.caseBody); 49 | resultDiv.append(" suite=" + data.suite.suiteId + "," + data.suite.suiteName); 50 | } 51 | 52 | function fresh4Update(data) { 53 | if (data) { 54 | jQuery('#suiteList').val(data.suite.suiteId); 55 | jQuery("#caseName").val(data.caseName); 56 | jQuery("#caseStatus").val(data.caseStatus); 57 | jQuery("#caseBody").val(data.caseBody); 58 | } else { 59 | jQuery("#caseName").val(data.caseName); 60 | jQuery("#caseStatus").val(""); 61 | jQuery("#caseBody").val(""); 62 | } 63 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/cases/testCases.js: -------------------------------------------------------------------------------- 1 | function loadCases(start, size) { 2 | checkSignIn(); 3 | restGet(ATUP_CASE_URI + TEST_CASE_PATH + "/cases?start=" + start + "&size=" + size, GET_METHOD, renderGetAll); 4 | } 5 | function renderGetAll(data) { 6 | var list = data.testCaseList; 7 | if (list == null) { 8 | jQuery("#casesDiv").html("No Test Case found."); 9 | } else { 10 | jQuery("#casesDiv").html( 11 | "
" + SPAN_BEGIN + "Case ID" + SPAN_BEGIN + "Case Name" + SPAN_BEGIN + "Case Status" + SPAN_BEGIN 12 | + "Case body" + SPAN_BEGIN2 + "Last Updated
"); 13 | jQuery.each(list, function (i, testCase) { 14 | var line = "
" + SPAN_BEGIN + testCase.caseId + "" + SPAN_BEGIN + "" + testCase.caseName + "" + SPAN_BEGIN + testCase.caseStatus + "" + SPAN_BEGIN + testCase.caseBody + "" + SPAN_BEGIN2 16 | + testCase.updateTime + "
"; 17 | jQuery("#casesDiv").append(line); 18 | }); 19 | } 20 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/cases/testSuite.js: -------------------------------------------------------------------------------- 1 | function createSuite() { 2 | var suiteName = $("#suiteName0").val(); 3 | var postData = JSON.stringify({suiteName: suiteName, suiteStatus: '1', suiteType: '1'}); 4 | restSet(ATUP_CASE_URI + TEST_SUITE_PATH, POST_METHOD, postData, renderEdit); 5 | } 6 | function updateSuite() { 7 | var suiteName = $("#suiteName").val(); 8 | var suiteStatus = $("#suiteStatus").val(); 9 | var suiteType = $("#suiteType").val(); 10 | var putData = JSON.stringify({suiteName: suiteName, suiteStatus: suiteStatus, suiteType: suiteType}); 11 | restSet(ATUP_CASE_URI + TEST_SUITE_PATH, PUT_METHOD, putData, renderEdit); 12 | } 13 | function renderEdit(data) { 14 | var resultDiv = jQuery('#resultDiv'); 15 | resultDiv.html("id=" + data.suiteId); 16 | resultDiv.append(" name=" + data.suiteName); 17 | resultDiv.append(" status=" + data.suiteStatus); 18 | resultDiv.append(" type=" + data.suiteType); 19 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/cases/testSuites.js: -------------------------------------------------------------------------------- 1 | function loadSuites(start, size) { 2 | checkSignIn(); 3 | jQuery("#suitesDiv").html("Loading..."); 4 | restGet(ATUP_CASE_URI + TEST_SUITE_PATH + "/suites?start=" + start + "&size=" + size, GET_METHOD, renderGetAll); 5 | } 6 | function renderGetAll(data) { 7 | var list = data.suiteList; 8 | if (list == null || list.length == 0) { 9 | jQuery("#suitesDiv").html("No Test Suite found."); 10 | } else { 11 | jQuery("#suitesDiv").html( 12 | "
" + SPAN_BEGIN + "Suite ID" + SPAN_BEGIN + "Suite Name" + SPAN_BEGIN + "Suite Status" + SPAN_BEGIN 13 | + "Suite Type
"); 14 | jQuery.each(list, function (i, suite) { 15 | var line = "
" + SPAN_BEGIN + suite.suiteId + "" + SPAN_BEGIN + suite.suiteName + "" + SPAN_BEGIN + suite.suiteStatus 16 | + "" + SPAN_BEGIN + suite.suiteType + "
"; 17 | jQuery("#suitesDiv").append(line); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/devices/device.js: -------------------------------------------------------------------------------- 1 | var query = window.location.search.substring(1); 2 | 3 | function initial() { 4 | checkSignIn(); 5 | if (query) { 6 | jQuery("#deviceIp").val(getValue(query, "deviceIp")); 7 | jQuery("#deviceName").val(getValue(query, "deviceName")); 8 | jQuery("#deviceType").val(getValue(query, "deviceType")); 9 | jQuery("#deviceStatus").val(getValue(query, "deviceStatus")); 10 | } 11 | restGet(ATUP_USER_URI + USER_PATH, GET_METHOD, renderUserList); 12 | } 13 | 14 | function renderUserList(data) { 15 | var list = data.userList; 16 | var html = ""; 17 | var userId; 18 | if (query) { 19 | userId = getValue(query, "userId"); 20 | } 21 | jQuery.each(list, function (i, user) { 22 | if (user.userId == userId) { 23 | html += ""; 29 | }); 30 | jQuery("#userList").empty().append(html); 31 | } 32 | 33 | function createDevice() { 34 | var deviceIp = $("#deviceIp0").val(); 35 | var deviceName = $("#deviceName0").val(); 36 | var deviceType = $("#deviceType0").val(); 37 | var postData = JSON.stringify({deviceHost: deviceIp, deviceName: deviceName, deviceType: deviceType, deviceStatus: DEVICE_STATUS_ERROR}); 38 | restSet(ATUP_DEVICE_URI + DEVICE_PATH, POST_METHOD, postData, renderEdit); 39 | } 40 | function updateDevice() { 41 | var deviceIp = $("#deviceIp").val(); 42 | var deviceName = $("#deviceName").val(); 43 | var deviceType = $("#deviceType").val(); 44 | var deviceStatus = $("#deviceStatus").val(); 45 | var userId = $("#userList").val(); 46 | var putData = JSON.stringify({deviceHost: deviceIp, deviceName: deviceName, deviceType: deviceType, deviceStatus: deviceStatus, user: {userId: userId}}); 47 | restSet(ATUP_DEVICE_URI + DEVICE_PATH, PUT_METHOD, putData, renderEdit); 48 | } 49 | function renderEdit(data) { 50 | var resultDiv = jQuery('#resultDiv'); 51 | resultDiv.html("id=" + data.deviceId); 52 | resultDiv.append(" name=" + data.deviceName); 53 | resultDiv.append(" host=" + data.deviceHost); 54 | resultDiv.append(" status=" + data.deviceStatus); 55 | resultDiv.append(" type=" + data.deviceType); 56 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/devices/devices.js: -------------------------------------------------------------------------------- 1 | function loadDevices() { 2 | checkSignIn(); 3 | jQuery("#devicesDiv").html("Loading..."); 4 | restCall(); 5 | setInterval(restCall, 10000); 6 | } 7 | function restCall() { 8 | var userRole = storage.getItem("userRole"); 9 | if (ROLE_DEVICE_MANAGER == userRole) { 10 | restGet(ATUP_DEVICE_URI + DEVICE_PATH + "/all", GET_METHOD, renderGetAll); 11 | } else { 12 | restGet(ATUP_DEVICE_URI + DEVICE_PATH, GET_METHOD, renderGetAll); 13 | } 14 | } 15 | function renderGetAll(data) { 16 | var list = data.deviceList; 17 | if (list == null || list.length == 0) { 18 | jQuery("#devicesDiv").html("No device for the current user."); 19 | } else { 20 | var userRole = storage.getItem("userRole"); 21 | if (ROLE_DEVICE_MANAGER == userRole) { 22 | jQuery("#devicesDiv").html( 23 | "
" + SPAN_BEGIN 24 | + "Device ID" + SPAN_BEGIN2 25 | + "Device Name" + SPAN_BEGIN2 26 | + "Device IP" + SPAN_BEGIN2 27 | + "Status" + SPAN_BEGIN2 28 | + "Last Updated" + SPAN_BEGIN2 29 | + "User" + SPAN_BEGIN2 30 | + "Manage
"); 31 | jQuery.each(list, function (i, device) { 32 | var line = "
" + SPAN_BEGIN 33 | + device.deviceId + "" + SPAN_BEGIN2 34 | + device.deviceName + "" + SPAN_BEGIN2 35 | + device.deviceHost + "" + SPAN_BEGIN2 36 | + device.deviceStatus + "" + SPAN_BEGIN2 37 | + device.updateTime + "" + SPAN_BEGIN2 38 | + device.user.userName + "" + SPAN_BEGIN2 39 | + "edit
"; 42 | jQuery("#devicesDiv").append(line); 43 | }); 44 | } else { 45 | jQuery("#devicesDiv").html( 46 | "
" + SPAN_BEGIN 47 | + "Device ID" + SPAN_BEGIN2 48 | + "Device Name" + SPAN_BEGIN2 49 | + "Device IP" + SPAN_BEGIN 50 | + "Status" + SPAN_BEGIN2 51 | + "Last Updated
"); 52 | jQuery.each(list, function (i, device) { 53 | var line = "
" + SPAN_BEGIN 54 | + device.deviceId + "" + SPAN_BEGIN2 55 | + device.deviceName + "" + SPAN_BEGIN2 56 | + device.deviceHost + "" + SPAN_BEGIN 57 | + device.deviceStatus + "" + SPAN_BEGIN2 58 | + device.updateTime + "" + "
"; 59 | jQuery("#devicesDiv").append(line); 60 | }); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/index_buildtime.js: -------------------------------------------------------------------------------- 1 | function load() { 2 | checkSignIn(); 3 | markVersion(); 4 | loadLinkByRole(); 5 | } 6 | function loadLinkByRole() { 7 | var userRole = storage.getItem("userRole"); 8 | if (userRole == ROLE_ADMIN) { 9 | jQuery('#userDiv').html( 10 | "
Users
" + 11 | "User List
" + 12 | "Manage User
"); 13 | } else if (userRole == ROLE_JOB_KILLER) { 14 | 15 | } else if (userRole == ROLE_DEVICE_MANAGER) { 16 | jQuery('#deviceDiv').append("Manage Device
"); 17 | } else if (userRole == ROLE_USER) { 18 | 19 | } 20 | } 21 | function markVersion() { 22 | jQuery('#buildDiv').html("Build Time: @buildtime@"); 23 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/jobs/testJob.js: -------------------------------------------------------------------------------- 1 | function initial() { 2 | checkSignIn(); 3 | var query = window.location.search.substring(1); 4 | jQuery("#caseId").val(getValue(query, "caseId")); 5 | jQuery("#caseName").val(getValue(query, "caseName")); 6 | restGet(ATUP_DEVICE_URI + DEVICE_PATH, GET_METHOD, renderDeviceList); 7 | var html = ""; 8 | jQuery("#priorityList").empty().append(html); 9 | } 10 | function renderDeviceList(data) { 11 | var list = data.deviceList; 12 | var html = ""; 13 | jQuery.each(list, function (i, device) { 14 | html += ""; 17 | }); 18 | jQuery("#deviceList").empty().append(html); 19 | } 20 | 21 | function createJob() { 22 | var deviceIp = jQuery("#deviceList").val(); 23 | var caseId = jQuery("#caseId").val(); 24 | var caseName = jQuery("#caseName").val(); 25 | var priority = jQuery("#priorityList").val(); 26 | var userId = storage.getItem("userId"); 27 | 28 | 29 | if (deviceIp && caseId && caseName && priority) { 30 | var postData = JSON.stringify({deviceIp: deviceIp, caseId: caseId, userId: userId, priority: priority, generatedTime: new Date()}); 31 | restSet(ATUP_CASE_URI + TEST_JOB_PATH, POST_METHOD, postData, afterCreate()); 32 | } else { 33 | jQuery('#resultDiv').html("Required parameter is missing, check the input parameters"); 34 | } 35 | } 36 | 37 | function afterCreate() { 38 | var resultDiv = jQuery('#resultDiv'); 39 | resultDiv.html(resultDiv.val() + " :: DONE."); 40 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/jobs/testJobs.js: -------------------------------------------------------------------------------- 1 | function loadJobs() { 2 | checkSignIn(); 3 | jQuery("#jobsDiv").html("Loading..."); 4 | restCall(); 5 | setInterval(restCall, 10000); 6 | } 7 | function restCall() { 8 | restGet(ATUP_CASE_URI + TEST_JOB_PATH, GET_METHOD, renderGetAll); 9 | } 10 | function renderGetAll(data) { 11 | var list = data.jobs; 12 | if (list == null || list.length == 0) { 13 | jQuery("#jobsDiv").html("No job is arranging."); 14 | } else { 15 | var userRole = storage.getItem("userRole"); 16 | if (ROLE_JOB_KILLER == userRole) { 17 | jQuery("#jobsDiv").html( 18 | "
" + SPAN_BEGIN 19 | + "Job Id" + SPAN_BEGIN 20 | + "Case Id" + SPAN_BEGIN2 21 | + "Device Ip" + SPAN_BEGIN 22 | + "User Id" + SPAN_BEGIN2 23 | + "Job Priority" + SPAN_BEGIN 24 | + "Create Time" + SPAN_BEGIN 25 | + "Manage
"); 26 | jQuery.each(list, function (i, jobInfo) { 27 | var line = "
" + SPAN_BEGIN 28 | + jobInfo.jobId + "" + SPAN_BEGIN 29 | + jobInfo.caseId + "" + SPAN_BEGIN2 30 | + jobInfo.deviceIp + "" + SPAN_BEGIN 31 | + jobInfo.userId + "" + SPAN_BEGIN2 32 | + jobInfo.priority + "" + SPAN_BEGIN 33 | + jobInfo.generatedTime + "" + SPAN_BEGIN 34 | + "
"; 35 | jQuery("#jobsDiv").append(line); 36 | }); 37 | } else { 38 | jQuery("#jobsDiv").html( 39 | "
" + SPAN_BEGIN 40 | + "Job Id" + SPAN_BEGIN 41 | + "Case Id" + SPAN_BEGIN 42 | + "Device Ip" + SPAN_BEGIN 43 | + "User Id" + SPAN_BEGIN2 44 | + "Job Priority" + SPAN_BEGIN 45 | + "Create Time
"); 46 | jQuery.each(list, function (i, jobInfo) { 47 | var line = "
" + SPAN_BEGIN 48 | + jobInfo.jobId + "" + SPAN_BEGIN 49 | + jobInfo.caseId + "" + SPAN_BEGIN 50 | + jobInfo.deviceIp + "" + SPAN_BEGIN 51 | + jobInfo.userId + "" + SPAN_BEGIN2 52 | + jobInfo.priority + "" + SPAN_BEGIN 53 | + jobInfo.generatedTime + "
"; 54 | jQuery("#jobsDiv").append(line); 55 | }); 56 | } 57 | } 58 | } 59 | function removeJob(jobId) { 60 | var jobInfo = JSON.stringify({jobId: jobId}); 61 | restSet(ATUP_CASE_URI + TEST_JOB_PATH, DELETE_METHOD, jobInfo, loadJobs()); 62 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/md5.js: -------------------------------------------------------------------------------- 1 | // https://github.com/blueimp/JavaScript-MD5 2 | // https://raw.github.com/blueimp/JavaScript-MD5/master/js/md5.min.js 3 | !function(a){"use strict";function b(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function c(a,b){return a<>>32-b}function d(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)}function e(a,b,c,e,f,g,h){return d(b&c|~b&e,a,b,f,g,h)}function f(a,b,c,e,f,g,h){return d(b&e|c&~e,a,b,f,g,h)}function g(a,b,c,e,f,g,h){return d(b^c^e,a,b,f,g,h)}function h(a,b,c,e,f,g,h){return d(c^(b|~e),a,b,f,g,h)}function i(a,c){a[c>>5]|=128<>>9<<4)+14]=c;var d,i,j,k,l,m=1732584193,n=-271733879,o=-1732584194,p=271733878;for(d=0;d>5]>>>b%32&255);return c}function k(a){var b,c=[];for(c[(a.length>>2)-1]=void 0,b=0;b>5]|=(255&a.charCodeAt(b/8))<16&&(e=i(e,8*a.length)),c=0;16>c;c+=1)f[c]=909522486^e[c],g[c]=1549556828^e[c];return d=i(f.concat(k(b)),512+8*b.length),j(i(g.concat(d),640))}function n(a){var b,c,d="0123456789abcdef",e="";for(c=0;c>>4&15)+d.charAt(15&b);return e}function o(a){return unescape(encodeURIComponent(a))}function p(a){return l(o(a))}function q(a){return n(p(a))}function r(a,b){return m(o(a),o(b))}function s(a,b){return n(r(a,b))}function t(a,b,c){return b?c?r(b,a):s(b,a):c?p(a):q(a)}"function"==typeof define&&define.amd?define(function(){return t}):a.md5=t}(this); -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/results/testResult.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feuyeux/jax-rs2-atup/b76284e518e641ca16dbe5b4cf7f4e308ad6cede/atup-page/src/main/webapp/js/results/testResult.js -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/results/testResults.js: -------------------------------------------------------------------------------- 1 | function loadResults(start, size) { 2 | checkSignIn(); 3 | jQuery("#resultsDiv").html("Loading..."); 4 | restGet(ATUP_CASE_URI + TEST_RESULT_PATH + "/results?start=" + start + "&size=" + size, GET_METHOD, renderGetAll); 5 | } 6 | function renderGetAll(data) { 7 | var list = data.resultList; 8 | if (list == null) { 9 | jQuery("#resultsDiv").html("No Test Result found."); 10 | } else { 11 | jQuery("#resultsDiv").html( 12 | "
" + SPAN_BEGIN 13 | + "Result ID" + SPAN_BEGIN2 14 | + "Result Status" + SPAN_BEGIN 15 | + "Owner" + SPAN_BEGIN 16 | + "Case Info" + SPAN_BEGIN4 17 | + "Result Body
"); 18 | jQuery.each(list, function (i, testResult) { 19 | var line = "
" + SPAN_BEGIN 20 | + testResult.resultId + "" + SPAN_BEGIN2 21 | + testResult.resultStatus + "" + SPAN_BEGIN 22 | + testResult.user.userName + "" + SPAN_BEGIN 23 | + testResult.testCase.caseName + "" + SPAN_BEGIN4 24 | + testResult.createTime + "..." + testResult.updateTime + "..." + testResult.resultBody + 25 | "
"; 26 | jQuery("#resultsDiv").append(line); 27 | }); 28 | } 29 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/users/user.js: -------------------------------------------------------------------------------- 1 | /*POST*/ 2 | function createUser() { 3 | var userName = jQuery.trim(jQuery("#userName0").val()); 4 | var password = jQuery("#password0").val(); 5 | var hashPassword = md5(password); 6 | var postData = JSON.stringify({userName: userName, passWord: hashPassword, userRole: 4, status: 0}); 7 | restSet(ATUP_USER_URI + USER_PATH, POST_METHOD, postData, renderCreate); 8 | } 9 | /*PUT*/ 10 | function updateUser() { 11 | var userName = jQuery.trim(jQuery("#userName").val()); 12 | var password = jQuery("#password").val(); 13 | var hashPassword = md5(password); 14 | var userRole = jQuery("#role").val(); 15 | var putData = JSON.stringify({userName: userName, passWord: hashPassword, userRole: userRole}); 16 | restSet(ATUP_USER_URI + USER_PATH, PUT_METHOD, putData, renderUpdate); 17 | } 18 | /*GET*/ 19 | function signIn() { 20 | var userName = jQuery("#userName").val(); 21 | var password = jQuery.trim(jQuery("#password").val()); 22 | var hashPassword = md5(password); 23 | var url = ATUP_USER_URI + SIGNIN_PATH + "?user=" + userName + "&password=" + hashPassword; 24 | restGet(url, GET_METHOD, renderSignIn); 25 | } 26 | /*RENDER*/ 27 | function renderCreate(data) { 28 | jQuery('#resultDiv').html("id=" + data.userId); 29 | } 30 | function renderUpdate(data) { 31 | var usersDiv = jQuery("#usersDiv"); 32 | usersDiv.html("
User ID"); 33 | usersDiv.append("User Name"); 34 | usersDiv.append("User Role
"); 35 | usersDiv.append("
"); 36 | usersDiv.append(data.userId); 37 | usersDiv.append(""); 38 | usersDiv.append(data.userName); 39 | usersDiv.append(""); 40 | usersDiv.append(data.userRole); 41 | usersDiv.append("
"); 42 | } 43 | function renderSignIn(data) { 44 | if (data.userId != null && data.userName != null && data.userRole != null) { 45 | storage.setItem("userId", data.userId); 46 | storage.setItem("userName", data.userName); 47 | storage.setItem("userRole", data.userRole); 48 | window.location.href = "index.html"; 49 | } else { 50 | //TODO 51 | } 52 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/js/users/users.js: -------------------------------------------------------------------------------- 1 | function loadUsers() { 2 | checkSignIn(); 3 | restGet(ATUP_USER_URI + USER_PATH, GET_METHOD, renderGetAll); 4 | } 5 | function renderGetAll(data) { 6 | var list = data.userList; 7 | if (list == null || list.length == 0) { 8 | jQuery("#usersDiv").html("No user found."); 9 | } else { 10 | jQuery("#usersDiv").html( 11 | "
User ID" 12 | + "User Name" 13 | + "User Role" 14 | + "User Status" 15 | + "Manage
"); 16 | jQuery.each(list, function (i, user) { 17 | var line = "
" 18 | + user.userId + "" 19 | + user.userName + "" 20 | + user.userRole + "" 21 | + user.status + "" 22 | + "
"; 23 | jQuery("#usersDiv").append(line); 24 | }); 25 | } 26 | } 27 | 28 | function disableUser(userId) { 29 | var putData = JSON.stringify({userId: userId, status: 1}); 30 | restSet(ATUP_USER_URI + USER_PATH, PUT_METHOD, putData, loadUsers); 31 | } -------------------------------------------------------------------------------- /atup-page/src/main/webapp/signIn.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sign In 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 23 | 24 | 25 |
User Name: 26 |
27 |
Password: 28 |
29 |
30 | 31 |
32 |
33 | Sign Up
34 | 35 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/signUp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Sign In 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
18 |
19 |
21 |
22 | 23 | 24 |
25 | Index
26 |
27 | 28 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/storageTest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/users/user.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | User Page 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | 18 | 24 |
25 | 26 |
Update User
27 | 28 |
29 |
Create User
30 | 31 |
32 | 33 | 34 |
35 |
36 | 37 | 38 |
39 |
40 | 41 |
42 |
43 |
45 |
46 |
47 |
49 |
50 |
51 |
52 | 53 |
54 |
55 | Index 56 | 57 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/users/users.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | User List 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 |
18 |
19 |
20 | Index 21 | 22 | -------------------------------------------------------------------------------- /atup-page/src/main/webapp/webjars/readme.txt: -------------------------------------------------------------------------------- 1 | this directory is only for nginx which is running out of jvm -------------------------------------------------------------------------------- /atup-test-station/mvn-eclipse.bat: -------------------------------------------------------------------------------- 1 | cd %1 2 | call mvn eclipse:clean && mvn -Dwtp.version=3.5.1 eclipse:eclipse -------------------------------------------------------------------------------- /atup-test-station/mvn-eclipse.sh: -------------------------------------------------------------------------------- 1 | cd $1 2 | mvn -Dwtp.version=3.5.1 eclipse:clean eclipse:eclipse 3 | mvn clean install -Dmaven.test.skip=true 4 | mvn dependency:sources 5 | -------------------------------------------------------------------------------- /atup-test-station/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | atup 6 | org.feuyeux.jaxrs2.atup 7 | 0.0.4-SNAPSHOT 8 | 9 | 10 | atup-test-station 11 | war 12 | ATUP Test Station 13 | 14 | 15 | atup-test-station 16 | 17 | 18 | org.apache.maven.plugins 19 | maven-war-plugin 20 | ${maven-war-plugin.version} 21 | 22 | false 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | CI 31 | 32 | 33 | 34 | org.apache.tomcat.maven 35 | tomcat7-maven-plugin 36 | 37 | 38 | pre-integration-test 39 | 40 | target/${project.build.finalName}.war 41 | /${project.build.finalName} 42 | 43 | 44 | redeploy 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.feuyeux.jaxrs2.atup 57 | atup-core 58 | ${project.version} 59 | 60 | 61 | 62 | org.apache.tomcat 63 | tomcat-servlet-api 64 | provided 65 | 66 | 67 | 68 | org.glassfish.jersey.containers 69 | jersey-container-servlet 70 | 71 | 72 | 73 | org.glassfish.jersey.media 74 | jersey-media-moxy 75 | 76 | 77 | 78 | org.glassfish.jersey.ext 79 | jersey-spring3 80 | 81 | 82 | 83 | org.springframework 84 | spring-core 85 | 86 | 87 | org.springframework 88 | spring-web 89 | compile 90 | 91 | 92 | org.springframework 93 | spring-test 94 | test 95 | 96 | 97 | org.springframework 98 | spring-tx 99 | 100 | 101 | org.springframework 102 | spring-orm 103 | 104 | 105 | 106 | junit 107 | junit 108 | test 109 | 110 | 111 | org.glassfish.jersey.test-framework 112 | jersey-test-framework-core 113 | test 114 | 115 | 116 | org.glassfish.jersey.test-framework.providers 117 | jersey-test-framework-provider-grizzly2 118 | test 119 | 120 | 121 | 122 | mysql 123 | mysql-connector-java 124 | 125 | 126 | org.eclipse.persistence 127 | eclipselink 128 | 129 | 130 | 131 | org.apache.logging.log4j 132 | log4j-api 133 | 134 | 135 | org.apache.logging.log4j 136 | log4j-core 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /atup-test-station/readme.md: -------------------------------------------------------------------------------- 1 | tomcat7-maven-plugin 2 | 3 | .m2/settings.xml 4 | 5 | Atup_Tomcat_Staging 6 | admin 7 | admin 8 | 9 | 10 | nano TOMCAT/conf/tomcat-users.xml 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | mvn clean install -Dtomcat.server.ip=192.168.1.181 -PCI -------------------------------------------------------------------------------- /atup-test-station/src/main/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | ATUP Test Station 6 | 7 | Container 8 | jdbc/AtupDataSource 9 | javax.sql.DataSource 10 | 11 | 12 | -------------------------------------------------------------------------------- /atup-test-station/src/main/java/org/feuyeux/jaxrs2/atup/station/TestStationApplication.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.station; 2 | 3 | import org.glassfish.jersey.server.ResourceConfig; 4 | 5 | import javax.ws.rs.ApplicationPath; 6 | 7 | @ApplicationPath("/rest-api/*") 8 | class TestStationApplication extends ResourceConfig { 9 | public TestStationApplication() { 10 | packages("org.feuyeux.jaxrs2.atup.station.resource"); 11 | } 12 | } -------------------------------------------------------------------------------- /atup-test-station/src/main/java/org/feuyeux/jaxrs2/atup/station/resource/AtupStationResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.station.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 4 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 5 | import org.feuyeux.jaxrs2.atup.core.constant.AtupVariable; 6 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 7 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 8 | import org.springframework.stereotype.Component; 9 | 10 | import javax.inject.Singleton; 11 | import javax.servlet.http.HttpServletRequest; 12 | import javax.ws.rs.*; 13 | import javax.ws.rs.core.Context; 14 | import javax.ws.rs.core.MediaType; 15 | import java.util.Date; 16 | 17 | @Singleton 18 | @Component 19 | @Path(AtupApi.TEST_STATION_PATH) 20 | public class AtupStationResource { 21 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(AtupStationResource.class.getName()); 22 | private Integer status = AtupParam.DEVICE_IDLE; 23 | 24 | public AtupStationResource() { 25 | 26 | } 27 | 28 | @GET 29 | public Integer keepALive(@Context HttpServletRequest request) { 30 | //log.info("Request host=" + request.getRemoteHost()); 31 | if (request != null) { 32 | log.info("keep-a-live :: Request host =" + request.getRemoteAddr()); 33 | } 34 | return status; 35 | } 36 | 37 | @POST 38 | @Produces(MediaType.APPLICATION_JSON) 39 | @Consumes(MediaType.APPLICATION_JSON) 40 | public AtupTestResult test(@Context HttpServletRequest request, AtupTestCase testCase) throws InterruptedException { 41 | if (request != null) { 42 | log.info("Test Case Launched :: Request host =" + request.getRemoteAddr()); 43 | } 44 | if (testCase != null) { 45 | log.info("Test Case Launched :: TestCase =" + testCase); 46 | } 47 | Date createTime = new Date(); 48 | long s = System.nanoTime(); 49 | status = AtupParam.DEVICE_RUNNING; 50 | final AtupTestResult testResult = new AtupTestResult(testCase, AtupParam.RESULT_SUCCESS, Long.toString(System.nanoTime() - s), createTime, createTime); 51 | Thread.sleep(AtupVariable.TESTING_TIMEOUT); 52 | status = AtupParam.DEVICE_IDLE; 53 | return testResult; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /atup-test-station/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | org.eclipse.persistence.jpa.PersistenceProvider 8 | java:/comp/env/jdbc/AtupDataSource 9 | java:/comp/env/jdbc/AtupDataSource 10 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 11 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 12 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 13 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 14 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.persistence.jpa.PersistenceProvider 23 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 24 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 25 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 26 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 27 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /atup-test-station/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /atup-test-station/src/main/resources/applicationContext0.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /atup-test-station/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %p %c{1.} [%t] %m %ex%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /atup-test-station/src/test/java/org/feuyeux/jaxrs2/atup/station/resource/TIAtupStationResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.station.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 4 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult; 6 | import org.feuyeux.jaxrs2.atup.core.rest.AtupRequest; 7 | import org.glassfish.jersey.server.ResourceConfig; 8 | import org.glassfish.jersey.test.JerseyTest; 9 | import org.glassfish.jersey.test.TestProperties; 10 | import org.junit.Test; 11 | 12 | import javax.ws.rs.client.Entity; 13 | import javax.ws.rs.core.Application; 14 | import javax.ws.rs.core.MediaType; 15 | import javax.ws.rs.core.Response; 16 | import java.util.concurrent.ExecutorService; 17 | import java.util.concurrent.Executors; 18 | 19 | public class TIAtupStationResource extends JerseyTest { 20 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(TIAtupStationResource.class.getName()); 21 | private final String resourcePath = "http://localhost:9998/station/"; 22 | 23 | @Override 24 | protected Application configure() { 25 | enable(TestProperties.LOG_TRAFFIC); 26 | enable(TestProperties.DUMP_ENTITY); 27 | ResourceConfig cfg = new ResourceConfig(); 28 | cfg.packages("org.feuyeux.jaxrs2.atup.station.resource"); 29 | return cfg; 30 | } 31 | 32 | @Test 33 | public void testKeepAlive() { 34 | final AtupRequest request = new AtupRequest<>(); 35 | final Integer result = request.rest(AtupRequest.GET, resourcePath, Integer.class); 36 | log.debug("testKeepAlive:" + result); 37 | } 38 | 39 | @Test 40 | public void testLaunch() { 41 | //http://localhost:9998/station/ 42 | AtupTestCase testCase = new AtupTestCase(); 43 | final Entity e = Entity.entity(testCase, MediaType.APPLICATION_JSON_TYPE); 44 | final Response response = target().path(AtupApi.TEST_STATION_PATH).request().post(e); 45 | final AtupTestResult result = response.readEntity(AtupTestResult.class); 46 | log.debug("testLaunch:" + result); 47 | } 48 | 49 | @Test 50 | public void testLaunch2() { 51 | AtupTestCase testCase = new AtupTestCase(); 52 | final AtupRequest request = new AtupRequest<>(); 53 | final AtupTestResult result = request.rest(AtupRequest.POST, resourcePath, null, null, MediaType.APPLICATION_JSON_TYPE, testCase, AtupTestResult.class); 54 | log.debug("testLaunch2:" + result); 55 | } 56 | 57 | @Test 58 | public void testDeviceStatus() throws InterruptedException { 59 | ExecutorService executorService = Executors.newFixedThreadPool(1); 60 | ExecutorService executorService2 = Executors.newFixedThreadPool(1); 61 | executorService.submit(new Runnable() { 62 | @Override 63 | public void run() { 64 | while (true) { 65 | testKeepAlive(); 66 | try { 67 | Thread.sleep(2000); 68 | } catch (InterruptedException e) { 69 | e.printStackTrace(); 70 | } 71 | } 72 | } 73 | }); 74 | 75 | executorService2.submit(new Runnable() { 76 | @Override 77 | public void run() { 78 | for (int i = 0; i < 5; i++) { 79 | testLaunch2(); 80 | try { 81 | Thread.sleep(3000); 82 | } catch (InterruptedException e) { 83 | e.printStackTrace(); 84 | } 85 | } 86 | } 87 | }); 88 | 89 | Thread.sleep(120000); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /atup-topology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/feuyeux/jax-rs2-atup/b76284e518e641ca16dbe5b4cf7f4e308ad6cede/atup-topology.png -------------------------------------------------------------------------------- /atup-user/mvn-eclipse.bat: -------------------------------------------------------------------------------- 1 | cd %1 2 | call mvn eclipse:clean && mvn -Dwtp.version=3.5.1 eclipse:eclipse -------------------------------------------------------------------------------- /atup-user/mvn-eclipse.sh: -------------------------------------------------------------------------------- 1 | cd $1 2 | mvn -Dwtp.version=3.5.1 eclipse:clean eclipse:eclipse 3 | mvn clean install -Dmaven.test.skip=true 4 | mvn dependency:sources 5 | -------------------------------------------------------------------------------- /atup-user/readme.md: -------------------------------------------------------------------------------- 1 | User Role: 2 | 1 Administrator 3 | 2 Job Killer 4 | 3 Super Device Manager 5 | 4 User 6 | 7 | User status: 8 | 0 normal 9 | 1 disable -------------------------------------------------------------------------------- /atup-user/src/main/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | ATUP User Management 6 | 7 | Container 8 | jdbc/AtupDataSource 9 | javax.sql.DataSource 10 | 11 | 12 | -------------------------------------------------------------------------------- /atup-user/src/main/java/org/feuyeux/jaxrs2/atup/user/AtupUserApplication.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.user; 2 | 3 | import org.feuyeux.jaxrs2.atup.user.resource.AtupUserResource; 4 | import org.glassfish.jersey.server.ResourceConfig; 5 | 6 | import javax.ws.rs.ApplicationPath; 7 | 8 | @ApplicationPath("/rest-api/*") 9 | class AtupUserApplication extends ResourceConfig { 10 | public AtupUserApplication() { 11 | register(AtupUserResource.class); 12 | register(org.feuyeux.jaxrs2.atup.core.util.AtupCrossDomainFilter.class); 13 | } 14 | } -------------------------------------------------------------------------------- /atup-user/src/main/java/org/feuyeux/jaxrs2/atup/user/resource/AtupUserResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.user.resource; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 4 | import org.feuyeux.jaxrs2.atup.core.constant.AtupParam; 5 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 6 | import org.feuyeux.jaxrs2.atup.core.info.AtupErrorCode; 7 | import org.feuyeux.jaxrs2.atup.core.info.AtupUserInfo; 8 | import org.feuyeux.jaxrs2.atup.core.info.AtupUserListInfo; 9 | import org.feuyeux.jaxrs2.atup.user.service.AtupUserService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | 13 | import javax.ws.rs.*; 14 | import javax.ws.rs.core.Context; 15 | import javax.ws.rs.core.HttpHeaders; 16 | import javax.ws.rs.core.MediaType; 17 | import javax.ws.rs.core.Response; 18 | import java.util.List; 19 | 20 | @Path(AtupApi.USER_PATH) 21 | @Component 22 | public class AtupUserResource { 23 | private final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(AtupUserResource.class.getName()); 24 | @Autowired 25 | AtupUserService service; 26 | 27 | public AtupUserResource() { 28 | 29 | } 30 | 31 | @POST 32 | @Produces(MediaType.APPLICATION_JSON) 33 | @Consumes(MediaType.APPLICATION_JSON) 34 | public javax.ws.rs.core.Response createUser(@Context final HttpHeaders headers, final AtupUserInfo userInfo) { 35 | Response response = checkRole(headers, AtupParam.USER_ADMIN); 36 | if (response == null) { 37 | return createUser(userInfo); 38 | } else { 39 | return response; 40 | } 41 | } 42 | 43 | public Response checkRole(HttpHeaders headers, Integer role) { 44 | Integer userId = Integer.valueOf(headers.getRequestHeader(AtupApi.ATUP_USER_HEAD).get(0)); 45 | Integer userRole = Integer.valueOf(headers.getRequestHeader(AtupApi.ATUP_USER_ROLE_HEAD).get(0)); 46 | if (userId == null) { 47 | final AtupUserInfo result = new AtupUserInfo("No user info found.", AtupErrorCode.UNAUTHORIZED_ERROR); 48 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(result).build(); 49 | } else { 50 | final AtupUser user = service.getUser(userId); 51 | if (!user.getUserRole().equals(role) || !userRole.equals(role)) { 52 | final AtupUserInfo result = new AtupUserInfo("No permission for this request.", AtupErrorCode.FORBIDDEN_ERROR); 53 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(result).build(); 54 | } else { 55 | return null; 56 | } 57 | } 58 | } 59 | 60 | private Response createUser(AtupUserInfo userInfo) { 61 | try { 62 | final AtupUser newUser = service.createUser(userInfo); 63 | final AtupUserInfo result = new AtupUserInfo(newUser); 64 | return Response.ok().entity(result).build(); 65 | } catch (final Exception e) { 66 | final AtupUserInfo result = new AtupUserInfo(e.getMessage(), AtupErrorCode.PERSIST_ERROR); 67 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(result).build(); 68 | } 69 | } 70 | 71 | @PUT 72 | @Produces(MediaType.APPLICATION_JSON) 73 | @Consumes(MediaType.APPLICATION_JSON) 74 | public javax.ws.rs.core.Response updateUser(final AtupUserInfo userInfo) { 75 | try { 76 | final AtupUser newUser = service.updateUser(userInfo); 77 | final AtupUserInfo result = new AtupUserInfo(newUser); 78 | return Response.ok().entity(result).build(); 79 | } catch (final Exception e) { 80 | final AtupUserInfo result = new AtupUserInfo(e.getMessage(), AtupErrorCode.PERSIST_ERROR); 81 | return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(result).build(); 82 | } 83 | } 84 | 85 | @GET 86 | @Path("{user}") 87 | @Produces(MediaType.APPLICATION_JSON) 88 | public AtupUserInfo getUser(@PathParam("user") final String userName) { 89 | final AtupUser user = service.getUser(userName); 90 | return new AtupUserInfo(user); 91 | } 92 | 93 | @GET 94 | @Produces(MediaType.APPLICATION_JSON) 95 | public AtupUserListInfo getUsers() { 96 | final List users = service.getUserList(); 97 | return new AtupUserListInfo(users); 98 | } 99 | 100 | @GET 101 | @Path("signin") 102 | @Produces(MediaType.APPLICATION_JSON) 103 | public AtupUserInfo getUser(@QueryParam("user") final String userName, @QueryParam("password") final String password) { 104 | try { 105 | final AtupUser user = service.getUser(userName.trim()); 106 | final AtupUserInfo result = new AtupUserInfo(user); 107 | if (result.getPassWord().equals(password)) { 108 | return result; 109 | } 110 | } catch (Exception e) { 111 | log.error(e.getMessage()); 112 | return new AtupUserInfo("Not found this user, please try again.", AtupErrorCode.PERSIST_ERROR); 113 | } 114 | return null; 115 | } 116 | } -------------------------------------------------------------------------------- /atup-user/src/main/java/org/feuyeux/jaxrs2/atup/user/service/AtupUserService.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.user.service; 2 | 3 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 4 | import org.feuyeux.jaxrs2.atup.core.info.AtupUserInfo; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | @Service 12 | public class AtupUserService { 13 | 14 | @Autowired 15 | org.feuyeux.jaxrs2.atup.core.dao.AtupUserDao dao; 16 | 17 | public AtupUser createUser(final AtupUserInfo userInfo) { 18 | final AtupUser user = new AtupUser(userInfo); 19 | return dao.save(user); 20 | } 21 | 22 | public AtupUser getUser(Integer id) { 23 | return dao.findById(id); 24 | } 25 | 26 | public AtupUser getUser(final String userName) { 27 | return dao.findByName(userName); 28 | } 29 | 30 | public List getUserList() { 31 | final List list = dao.findAll(); 32 | final List result = new ArrayList<>(); 33 | for (AtupUser aList : list) { 34 | result.add(new AtupUserInfo(aList)); 35 | } 36 | return result; 37 | } 38 | 39 | public AtupUser updateUser(final AtupUserInfo userInfo) { 40 | final AtupUser updatedUser = dao.update(new AtupUser(userInfo)); 41 | return updatedUser; 42 | } 43 | } -------------------------------------------------------------------------------- /atup-user/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | org.eclipse.persistence.jpa.PersistenceProvider 8 | java:/comp/env/jdbc/AtupDataSource 9 | java:/comp/env/jdbc/AtupDataSource 10 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 11 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 12 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 13 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 14 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.persistence.jpa.PersistenceProvider 23 | org.feuyeux.jaxrs2.atup.core.domain.AtupDevice 24 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestCase 25 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestResult 26 | org.feuyeux.jaxrs2.atup.core.domain.AtupTestSuite 27 | org.feuyeux.jaxrs2.atup.core.domain.AtupUser 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /atup-user/src/main/resources/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /atup-user/src/main/resources/applicationContext2.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /atup-user/src/main/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d %p %c{1.} [%t] %m %ex%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /atup-user/src/main/resources/section/staging.properties: -------------------------------------------------------------------------------- 1 | db.server.address=localhost 2 | db.driver=com.mysql.jdbc.Driver 3 | db.url=jdbc:mysql://${db.server.address}:3306/jaxrs2_atup 4 | db.username=root 5 | db.password=root 6 | -------------------------------------------------------------------------------- /atup-user/src/test/java/org/feuyeux/jaxrs2/atup/user/dao/TUAtupUserDao.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.user.dao; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.feuyeux.jaxrs2.atup.core.dao.AtupUserDao; 6 | import org.feuyeux.jaxrs2.atup.core.domain.AtupUser; 7 | import org.feuyeux.jaxrs2.atup.core.fake.CreateUser; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.test.context.ContextConfiguration; 13 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 14 | 15 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 16 | @RunWith(SpringJUnit4ClassRunner.class) 17 | public class TUAtupUserDao { 18 | private final Logger log = LogManager.getLogger(TUAtupUserDao.class.getName()); 19 | 20 | @Autowired 21 | private AtupUserDao dao; 22 | 23 | @Test 24 | public void testCreateUser() { 25 | final AtupUser user = CreateUser.buildUser(); 26 | final AtupUser newUser = dao.save(user); 27 | log.info(newUser); 28 | Assert.assertEquals(user.getUserName(), newUser.getUserName()); 29 | } 30 | 31 | @Test 32 | public void testUpdateAndDeleteUser() { 33 | final AtupUser user = CreateUser.buildUser(); 34 | final AtupUser newUser = dao.save(user); 35 | newUser.setUserName(CreateUser.TEST_NAME1); 36 | final AtupUser updatedUser = dao.update(newUser); 37 | Assert.assertEquals(CreateUser.TEST_NAME1, updatedUser.getUserName()); 38 | 39 | final boolean deleted = dao.remove(updatedUser.getUserId()); 40 | Assert.assertEquals(true, deleted); 41 | } 42 | 43 | @Test 44 | public void testFindById() { 45 | final AtupUser user = CreateUser.buildUser(); 46 | final AtupUser newUser = dao.save(user); 47 | final AtupUser findUser = dao.findById(newUser.getUserId()); 48 | Assert.assertEquals(user.getUserName(), findUser.getUserName()); 49 | } 50 | 51 | @Test 52 | public void testFindByName() { 53 | final AtupUser user = CreateUser.buildUser(); 54 | final AtupUser newUser = dao.save(user); 55 | log.info(newUser); 56 | final AtupUser findUser = dao.findByName(newUser.getUserName()); 57 | Assert.assertEquals(user.getUserName(), findUser.getUserName()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /atup-user/src/test/java/org/feuyeux/jaxrs2/atup/user/resource/TIAtupUserResource.java: -------------------------------------------------------------------------------- 1 | package org.feuyeux.jaxrs2.atup.user.resource; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.feuyeux.jaxrs2.atup.core.constant.AtupApi; 6 | import org.feuyeux.jaxrs2.atup.core.fake.CreateUser; 7 | import org.feuyeux.jaxrs2.atup.core.info.AtupErrorCode; 8 | import org.feuyeux.jaxrs2.atup.core.info.AtupUserInfo; 9 | import org.glassfish.jersey.server.ResourceConfig; 10 | import org.glassfish.jersey.test.JerseyTest; 11 | import org.glassfish.jersey.test.TestProperties; 12 | import org.junit.Assert; 13 | import org.junit.Test; 14 | import org.junit.runner.RunWith; 15 | import org.springframework.test.context.ContextConfiguration; 16 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 17 | 18 | import javax.ws.rs.client.Entity; 19 | import javax.ws.rs.client.Invocation; 20 | import javax.ws.rs.core.Application; 21 | import javax.ws.rs.core.MediaType; 22 | import javax.ws.rs.core.Response; 23 | 24 | @ContextConfiguration(locations = {"classpath:applicationContext2.xml"}) 25 | @RunWith(SpringJUnit4ClassRunner.class) 26 | public class TIAtupUserResource extends JerseyTest { 27 | private final Logger log = LogManager.getLogger(TIAtupUserResource.class.getName()); 28 | 29 | @Override 30 | protected Application configure() { 31 | enable(TestProperties.LOG_TRAFFIC); 32 | enable(TestProperties.DUMP_ENTITY); 33 | return new ResourceConfig(AtupUserResource.class); 34 | } 35 | 36 | @Test 37 | public void testCreateUser() { 38 | final AtupUserInfo user = CreateUser.buildUserInfo(); 39 | final Entity e = Entity.entity(user, MediaType.APPLICATION_JSON_TYPE); 40 | final Response response = target().path(AtupApi.USER_PATH).request().post(e); 41 | final AtupUserInfo result = response.readEntity(AtupUserInfo.class); 42 | if (result.getStatusCode() == AtupErrorCode.NONE) { 43 | Assert.assertEquals(user.getUserName(), result.getUserName()); 44 | } else { 45 | Assert.fail(); 46 | log.info(result.getErrorInfo()); 47 | } 48 | } 49 | 50 | @Test 51 | public void testGetUser() { 52 | String userName = null; 53 | final AtupUserInfo user = CreateUser.buildUserInfo(); 54 | final Entity userEntity = Entity.entity(user, MediaType.APPLICATION_JSON_TYPE); 55 | final Invocation.Builder invocationBuilder = target().path(AtupApi.USER_PATH).request(); 56 | final Response response = invocationBuilder.post(userEntity); 57 | final AtupUserInfo result = response.readEntity(AtupUserInfo.class); 58 | if (result.getStatusCode() == AtupErrorCode.NONE) { 59 | userName = result.getUserName(); 60 | Assert.assertEquals(user.getUserName(), result.getUserName()); 61 | } else { 62 | Assert.fail(); 63 | log.info(result.getErrorInfo()); 64 | } 65 | 66 | if (userName != null) { 67 | final AtupUserInfo atupUserInfo = target().path(AtupApi.USER_PATH).path(userName).request().get(AtupUserInfo.class); 68 | Assert.assertEquals(userName, atupUserInfo.getUserName()); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /document/atup-ddl/atup-case.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `jaxrs2_atup`; 2 | USE `jaxrs2_atup`; 3 | 4 | DROP TABLE IF EXISTS `test_case`; 5 | CREATE TABLE `test_case` ( 6 | `case_id` int(11) NOT NULL AUTO_INCREMENT, 7 | `case_name` varchar(255) DEFAULT NULL, 8 | `case_body` varchar(255) DEFAULT NULL, 9 | `case_status` int(11) DEFAULT NULL, 10 | `create_time` datetime DEFAULT NULL, 11 | `update_time` datetime DEFAULT NULL, 12 | `suiteId` int(11) DEFAULT NULL, 13 | PRIMARY KEY (`case_id`), 14 | UNIQUE KEY `case_id` (`case_id`), 15 | UNIQUE KEY `case_name` (`case_name`), 16 | KEY `FK_test_case_suiteId` (`suiteId`), 17 | CONSTRAINT `FK_test_case_suiteId` FOREIGN KEY (`suiteId`) REFERENCES `test_suite` (`suite_id`) 18 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /document/atup-ddl/atup-device.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `jaxrs2_atup`; 2 | USE `jaxrs2_atup`; 3 | 4 | DROP TABLE IF EXISTS `atup_device`; 5 | CREATE TABLE `atup_device` ( 6 | `device_id` int(11) NOT NULL AUTO_INCREMENT, 7 | `device_host` varchar(255) DEFAULT NULL, 8 | `device_name` varchar(255) DEFAULT NULL, 9 | `device_type` int(11) DEFAULT NULL, 10 | `device_status` int(11) DEFAULT NULL, 11 | `userId` int(11) DEFAULT NULL, 12 | `create_time` datetime DEFAULT NULL, 13 | `update_time` datetime DEFAULT NULL, 14 | PRIMARY KEY (`device_id`), 15 | UNIQUE KEY `device_id` (`device_id`), 16 | UNIQUE KEY `device_host` (`device_host`), 17 | UNIQUE KEY `device_name` (`device_name`), 18 | KEY `FK_atup_device_userId` (`userId`), 19 | CONSTRAINT `FK_atup_device_userId` FOREIGN KEY (`userId`) REFERENCES `atup_user` (`user_id`) 20 | )ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /document/atup-ddl/atup-result.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `jaxrs2_atup`; 2 | USE `jaxrs2_atup`; 3 | 4 | DROP TABLE IF EXISTS `test_result`; 5 | CREATE TABLE `test_result` ( 6 | `result_id` int(11) NOT NULL AUTO_INCREMENT, 7 | `result_body` varchar(255) DEFAULT NULL, 8 | `result_status` int(11) DEFAULT NULL, 9 | `caseId` int(11) DEFAULT NULL, 10 | `deviceId` int(11) DEFAULT NULL, 11 | `userId` int(11) DEFAULT NULL, 12 | `create_time` datetime DEFAULT NULL, 13 | `update_time` datetime DEFAULT NULL, 14 | PRIMARY KEY (`result_id`), 15 | UNIQUE KEY `result_id` (`result_id`), 16 | KEY `FK_test_result_caseId` (`caseId`), 17 | KEY `FK_test_result_userId` (`userId`), 18 | KEY `FK_test_result_deviceId` (`deviceId`), 19 | CONSTRAINT `FK_test_result_caseId` FOREIGN KEY (`caseId`) REFERENCES `test_case` (`case_id`), 20 | CONSTRAINT `FK_test_result_deviceId` FOREIGN KEY (`deviceId`) REFERENCES `atup_device` (`device_id`), 21 | CONSTRAINT `FK_test_result_userId` FOREIGN KEY (`userId`) REFERENCES `atup_user` (`user_id`) 22 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -------------------------------------------------------------------------------- /document/atup-ddl/atup-suite.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS `jaxrs2_atup`; 2 | USE `jaxrs2_atup`; 3 | 4 | DROP TABLE IF EXISTS `test_suite`; 5 | CREATE TABLE `test_suite` ( 6 | `suite_id` int(11) NOT NULL AUTO_INCREMENT, 7 | `suite_name` varchar(255) DEFAULT NULL, 8 | `suite_status` int(11) DEFAULT NULL, 9 | `suite_type` int(11) DEFAULT NULL, 10 | PRIMARY KEY (`suite_id`), 11 | UNIQUE KEY `suite_id` (`suite_id`), 12 | UNIQUE KEY `suite_name` (`suite_name`) 13 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 14 | 15 | INSERT INTO `jaxrs2_atup`.`test_suite`(`suite_id`,`suite_name`,`suite_status`,`suite_type`) 16 | VALUES (1,'Performance Test',1,2), 17 | (2,'GUI Test',1,1), 18 | (3,'Unit Test',1,1), 19 | (4,'Integration Test',1,1), 20 | (5,'System Test',1,1); -------------------------------------------------------------------------------- /document/atup-ddl/atup-user.sql: -------------------------------------------------------------------------------- 1 | DROP DATABASE IF EXISTS `jaxrs2_atup`; 2 | CREATE DATABASE `jaxrs2_atup`; 3 | USE `jaxrs2_atup`; 4 | 5 | DROP TABLE IF EXISTS `atup_user`; 6 | CREATE TABLE `atup_user` ( 7 | `user_id` int(11) NOT NULL AUTO_INCREMENT, 8 | `user_name` varchar(255) DEFAULT NULL, 9 | `user_pwd` varchar(255) DEFAULT NULL, 10 | `user_role` int(11) DEFAULT NULL, 11 | `user_status` int(11) DEFAULT NULL, 12 | PRIMARY KEY (`user_id`), 13 | UNIQUE KEY `user_id` (`user_id`), 14 | UNIQUE KEY `user_name` (`user_name`) 15 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 16 | 17 | INSERT INTO `jaxrs2_atup`.`atup_user`(`user_id`,`user_name`,`user_pwd`,`user_role`,`user_status`) 18 | VALUES (1,'atupAdmin','650b81ee61374ef758f6e6b8ab68426e',1,0), 19 | (2,'atupJobKiller','650b81ee61374ef758f6e6b8ab68426e',2,0), 20 | (3,'atupDeviceKeeper','650b81ee61374ef758f6e6b8ab68426e',3,0), 21 | (4,'xer','faa709c5035aea00f9efb278f2ad5df0',4,0); -------------------------------------------------------------------------------- /document/curl-script/detect-devices.sh: -------------------------------------------------------------------------------- 1 | curl -X POST http://192.168.1.180:8080/atup-device/rest-api/devices/status -------------------------------------------------------------------------------- /document/curl-script/launch-jobs.sh: -------------------------------------------------------------------------------- 1 | curl -X POST http://192.168.1.180:8080/atup-case/rest-api/testjobs/jobs?count=5 -------------------------------------------------------------------------------- /document/job_flow_test_log.txt: -------------------------------------------------------------------------------- 1 | add devices 2 | add cases 3 | curl -X POST http://localhost:8080/atup-device/rest-api/devices/status 4 | 5 | http://localhost:8080/atup-page/devices/devices.html 6 | Device IDDevice NameDevice IPStatusLast Updated 7 | 1LocalHostlocalhost022/01/2014 10:00:37 8 | 2TestStation1192.168.1.180023/01/2014 01:54:13 9 | 3TestStation2192.168.1.181023/01/2014 01:58:20 10 | 11 | http://localhost:8080/atup-page/cases/testCases.html 12 | Case IDCase NameCase StatusCase bodyLast Updated 13 | 1C11aaa22/01/2014 01:14:25 14 | 2C21bbb22/01/2014 02:25:20 15 | 3C31ccc22/01/2014 02:25:25 16 | 4C41ddd22/01/2014 09:35:18 17 | 5C51eee22/01/2014 09:35:25 18 | 19 | http://localhost:8080/atup-page/jobs/runningJobs.html 20 | Job IdCase IdDevice IpUser IdJob PriorityCreate Time 21 | 01192.168.1.180405861190495510 22 | 34192.168.1.181405905300964951 23 | 12192.168.1.180415883712598472 24 | 45localhost415914636399995 25 | 23192.168.1.180425892445249335 26 | 27 | SELECT 28 | * 29 | FROM 30 | jaxrs2_atup.test_result 31 | ORDER BY 32 | create_time DESC 33 | LIMIT 0, 34 | 10 35 | 36 | curl -X POST http://localhost:8080/atup-case/rest-api/testjobs/jobs?count=5 -------------------------------------------------------------------------------- /document/nginx/nginx_cross_domain.txt: -------------------------------------------------------------------------------- 1 | add_header 'Access-Control-Allow-Origin' '*'; 2 | add_header 'Access-Control-Allow-Credentials' 'true'; 3 | add_header 'Access-Control-Allow-Headers' 'origin,Content-Type,Accept,Atup-User,Atup-UserRole'; 4 | add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS, HEAD'; 5 | add_header 'Access-Control-Max-Age' '1209600'; -------------------------------------------------------------------------------- /mvn-eclipse-all.bat: -------------------------------------------------------------------------------- 1 | cd atup-case 2 | call mvn-eclipse.bat 3 | cd .. 4 | cd atup-device 5 | call mvn-eclipse.bat 6 | cd .. 7 | cd atup-user 8 | call mvn-eclipse.bat 9 | cd .. 10 | cd atup-test-station 11 | call mvn-eclipse.bat 12 | cd .. 13 | -------------------------------------------------------------------------------- /mvn-eclipse-all.sh: -------------------------------------------------------------------------------- 1 | atup-case/mvn-eclipse.sh 2 | atup-device/mvn-eclipse.sh 3 | atup-user/mvn-eclipse.sh 4 | atup-test-station/mvn-eclipse.sh 5 | 6 | --------------------------------------------------------------------------------