Skip to content

Commit

Permalink
Add portal test configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
yiming187 committed Mar 12, 2016
1 parent 6938022 commit 30bade8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ public Page<App> list(@PageableDefault(size = 50) Pageable pageable) {
}

@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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.ctrip.apollo.portal;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class PortalApplicationTestConfiguration {

}
Original file line number Diff line number Diff line change
@@ -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());
}
}
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.1.0</version>
<version>4.1.0</version>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit 30bade8

Please sign in to comment.