Skip to content

Commit

Permalink
分拆springside-core 为 springside-utils 和 springside-core, 新的example1将只依…
Browse files Browse the repository at this point in the history
…赖springside-utils
  • Loading branch information
Calvin committed Oct 11, 2014
1 parent 93d4fbb commit 4a63d82
Show file tree
Hide file tree
Showing 23 changed files with 445 additions and 7 deletions.
15 changes: 10 additions & 5 deletions modules/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<name>Springside :: Module :: Core</name>

<dependencies>
<dependency>
<groupId>org.springside</groupId>
<artifactId>springside-utils</artifactId>
</dependency>

<!-- PERSISTENCE begin -->
<dependency>
<groupId>org.hibernate</groupId>
Expand Down Expand Up @@ -112,6 +117,11 @@
<artifactId>logback-classic</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<optional>true</optional>
</dependency>
<!-- LOGGING end -->

<!-- TEST MODULE begin -->
Expand Down Expand Up @@ -177,11 +187,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>
<!-- TEST end -->
</dependencies>

Expand Down
6 changes: 6 additions & 0 deletions modules/parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
<dependencyManagement>
<dependencies>
<!-- SPRINGSIDE MODULES begin -->
<dependency>
<groupId>org.springside</groupId>
<artifactId>springside-utils</artifactId>
<version>${springside.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springside</groupId>
<artifactId>springside-core</artifactId>
Expand Down
1 change: 1 addition & 0 deletions modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<modules>
<module>parent</module>
<module>utils</module>
<module>core</module>
<module>extension</module>
<module>metrics</module>
Expand Down
6 changes: 6 additions & 0 deletions modules/utils/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
echo [INFO] Install jar to local repository.

cd %~dp0
call mvn clean install
pause
5 changes: 5 additions & 0 deletions modules/utils/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

echo "[INFO] Install jar to local repository."

mvn clean install
124 changes: 124 additions & 0 deletions modules/utils/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springside</groupId>
<artifactId>springside-parent</artifactId>
<version>4.3.0-SNAPSHOT</version>
<relativePath>../parent/</relativePath>
</parent>
<artifactId>springside-utils</artifactId>
<packaging>jar</packaging>
<name>Springside :: Module :: Utils</name>

<dependencies>
<!-- UTILS begin -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<optional>true</optional>
</dependency>
<!-- UTILS end -->

<!-- LOGGING begin -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<optional>true</optional>
</dependency>
<!-- LOGGING end -->

<!-- TEST begin -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>

</dependencies>

<build>
<plugins>
<!-- source attach plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- 打包测试用的jar包,classfier为tests -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<includes>
<include>org/springside/modules/test/**/*.class</include>
<include>jetty/webdefault-windows.xml</include>
</includes>
<excludes>
<exclude>org/springside/modules/test/**/*Test.class</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>

<!-- enforcer, 规则统一定义在parent -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2005, 2014 springside.github.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
*******************************************************************************/
package org.springside.modules.test.data;

import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
* 随机测试数据生成工具类.
*
* @author calvin
*/
public class RandomData {

private static Random random = new Random();

/**
* 返回随机ID.
*/
public static long randomId() {
return random.nextLong();
}

/**
* 返回随机名称, prefix字符串+5位随机数字.
*/
public static String randomName(String prefix) {
return prefix + random.nextInt(10000);
}

/**
* 从输入list中随机返回一个对象.
*/
public static <T> T randomOne(List<T> list) {
Collections.shuffle(list);
return list.get(0);
}

/**
* 从输入list中随机返回n个对象.
*/
public static <T> List<T> randomSome(List<T> list, int n) {
Collections.shuffle(list);
return list.subList(0, n);
}

/**
* 从输入list中随机返回随机个对象.
*/
public static <T> List<T> randomSome(List<T> list) {
int size = random.nextInt(list.size());
if (size == 0) {
size = 1;
}
return randomSome(list, size);
}
}
Loading

0 comments on commit 4a63d82

Please sign in to comment.