diff --git a/.gitignore b/.gitignore index d33905fd3cc407a90aca15cc22398ed7e6ddd537..9136753b57e7138fecb40be2d33650a934f08aae 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,12 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +# Eclipse .classpath .project target - .settings + +# Idea +.idea +*.iml \ No newline at end of file diff --git a/apollo-configserver/src/test/resources/data.sql b/apollo-configserver/src/test/resources/data.sql deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/apollo-configserver/src/test/resources/schema.sql b/apollo-configserver/src/test/resources/schema.sql deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java index c697a30ff4b2b1f753961ba511aaf944daa81b7f..b238603a0e3ad946816e2445ab279434ce1a2dd7 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java @@ -26,12 +26,8 @@ public class AppController { } @RequestMapping(value = "", method = RequestMethod.POST) - public App create() { - App ramdomApp = new App(); - ramdomApp.setId(String.valueOf(System.currentTimeMillis())); - ramdomApp.setName("new app " + System.currentTimeMillis()); - ramdomApp.setOwner("owner " + System.currentTimeMillis()); - ramdomApp.setCreateTimestamp(new Date()); - return appRepository.save(ramdomApp); + public App create(App app) { + app.setCreateTimestamp(new Date()); + return appRepository.save(app); } } diff --git a/apollo-portal/src/test/java/com/ctrip/apollo/portal/PortalApplicationTestConfiguration.java b/apollo-portal/src/test/java/com/ctrip/apollo/portal/PortalApplicationTestConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..42edfd3ef2bed02d9d79a73646b1782f98d12410 --- /dev/null +++ b/apollo-portal/src/test/java/com/ctrip/apollo/portal/PortalApplicationTestConfiguration.java @@ -0,0 +1,8 @@ +package com.ctrip.apollo.portal; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class PortalApplicationTestConfiguration { + +} diff --git a/apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java b/apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java new file mode 100644 index 0000000000000000000000000000000000000000..467361790b9a28c87c6b2a9d2f940133adeddbee --- /dev/null +++ b/apollo-portal/src/test/java/com/ctrip/apollo/portal/repository/AppRepositoryTest.java @@ -0,0 +1,35 @@ +package com.ctrip.apollo.portal.repository; + +import java.util.Date; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.ctrip.apollo.portal.PortalApplicationTestConfiguration; +import com.ctrip.apollo.portal.entities.App; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = PortalApplicationTestConfiguration.class) +public class AppRepositoryTest { + + @Autowired + AppRepository repository; + + @Test + public void testCreate() { + Assert.assertEquals(0, repository.count()); + + App ramdomApp = new App(); + ramdomApp.setId(String.valueOf(System.currentTimeMillis())); + ramdomApp.setName("new app " + System.currentTimeMillis()); + ramdomApp.setOwner("owner " + System.currentTimeMillis()); + ramdomApp.setCreateTimestamp(new Date()); + repository.save(ramdomApp); + + Assert.assertEquals(1, repository.count()); + } +} diff --git a/apollo-portal/src/test/resources/data.sql b/apollo-portal/src/test/resources/data.sql deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/apollo-portal/src/test/resources/schema.sql b/apollo-portal/src/test/resources/schema.sql deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/pom.xml b/pom.xml index b7311abdca91fd43823ea7e864915220758cd8af..538247044b7ebdbcd83a05034cee640578048b42 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ org.eluder.coveralls coveralls-maven-plugin - 3.1.0 + 4.1.0