diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-08-08 09:43:11 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-08-08 09:43:21 +0200 |
commit | 72f0502fda8bf96f9f068ca8e6b6e09a66900c5b (patch) | |
tree | 7253e34f54417208a810aa0163d5f5adaeb2b040 /server | |
parent | 1a431d25b96e4f2d080e3015ee518e1ad01bcd13 (diff) | |
download | sonarqube-72f0502fda8bf96f9f068ca8e6b6e09a66900c5b.tar.gz sonarqube-72f0502fda8bf96f9f068ca8e6b6e09a66900c5b.zip |
SONAR-4898 - Created a DummyOKApplication for Unit test of ProcessWrapper
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-process-test/pom.xml | 19 | ||||
-rw-r--r-- | server/sonar-process-test/src/main/java/org/sonar/application/DummyOkApp.java (renamed from server/sonar-process-test/src/main/java/org/sonar/DummyOKApplication.java) | 14 | ||||
-rw-r--r-- | server/sonar-process-test/src/main/resources/org/sonar/application/logback.xml (renamed from server/sonar-process-test/src/test/resources/logback-test.xml) | 14 | ||||
-rw-r--r-- | server/sonar-process-test/src/main/resources/org/sonar/search/logback.xml | 35 | ||||
-rw-r--r-- | server/sonar-process/pom.xml | 35 | ||||
-rw-r--r-- | server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java | 8 |
6 files changed, 64 insertions, 61 deletions
diff --git a/server/sonar-process-test/pom.xml b/server/sonar-process-test/pom.xml index 67b012ae4d2..94c2090e448 100644 --- a/server/sonar-process-test/pom.xml +++ b/server/sonar-process-test/pom.xml @@ -12,7 +12,7 @@ <artifactId>sonar-process-test</artifactId> <packaging>jar</packaging> - <name>SonarQube :: Search</name> + <name>SonarQube :: Process :: Test</name> <description>Wrapper to start Elasticsearch</description> <dependencies> @@ -22,10 +22,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.elasticsearch</groupId> - <artifactId>elasticsearch</artifactId> - </dependency> - <dependency> <groupId>com.google.code.findbugs</groupId> <artifactId>jsr305</artifactId> <scope>provided</scope> @@ -68,6 +64,18 @@ <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <addClasspath>false</addClasspath> + <mainClass>org.sonar.application.DummyOkApp</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.3</version> <executions> @@ -77,6 +85,7 @@ <goal>shade</goal> </goals> <configuration> + <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope> <minimizeJar>true</minimizeJar> </configuration> </execution> diff --git a/server/sonar-process-test/src/main/java/org/sonar/DummyOKApplication.java b/server/sonar-process-test/src/main/java/org/sonar/application/DummyOkApp.java index ab0f939ed29..99adbd03125 100644 --- a/server/sonar-process-test/src/main/java/org/sonar/DummyOKApplication.java +++ b/server/sonar-process-test/src/main/java/org/sonar/application/DummyOkApp.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar; +package org.sonar.application; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,11 +26,11 @@ import org.sonar.process.Props; import java.util.Properties; -public class DummyOKApplication extends MonitoredProcess { +public class DummyOkApp extends MonitoredProcess { - private static final Logger LOGGER = LoggerFactory.getLogger(DummyOKApplication.class); + private static final Logger LOGGER = LoggerFactory.getLogger(DummyOkApp.class); - protected DummyOKApplication(Props props) throws Exception { + protected DummyOkApp(Props props) throws Exception { super(props); } @@ -49,10 +49,10 @@ public class DummyOKApplication extends MonitoredProcess { return false; } - public static void main(String... args) throws Exception { + public static void main(String[] args) throws Exception { Props props = new Props(new Properties()); - props.set(MonitoredProcess.NAME_PROPERTY, DummyOKApplication.class.getSimpleName()); - new DummyOKApplication(props).start(); + props.set(MonitoredProcess.NAME_PROPERTY, DummyOkApp.class.getSimpleName()); + new DummyOkApp(props).start(); System.exit(1); } } diff --git a/server/sonar-process-test/src/test/resources/logback-test.xml b/server/sonar-process-test/src/main/resources/org/sonar/application/logback.xml index ff2270cc122..933930557b9 100644 --- a/server/sonar-process-test/src/test/resources/logback-test.xml +++ b/server/sonar-process-test/src/main/resources/org/sonar/application/logback.xml @@ -10,19 +10,6 @@ <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>INFO</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> - <pattern> - %d{yyyy.MM.dd HH:mm:ss} %-5level %msg%n - </pattern> - </encoder> - </appender> - - <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern> %d{yyyy.MM.dd HH:mm:ss} %-5level %msg%n @@ -34,5 +21,4 @@ <level value="DEBUG"/> <appender-ref ref="CONSOLE"/> </root> - </configuration> diff --git a/server/sonar-process-test/src/main/resources/org/sonar/search/logback.xml b/server/sonar-process-test/src/main/resources/org/sonar/search/logback.xml deleted file mode 100644 index 648ece82e28..00000000000 --- a/server/sonar-process-test/src/main/resources/org/sonar/search/logback.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<!-- - Configuration for default logger. Only used while embedded server is starting, - before proper logging configuration is loaded. - - See http://logback.qos.ch/manual/configuration.html ---> -<configuration debug="false"> - <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/> - - <appender name="LOGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <File>${sonar.path.logs}/search.log</File> - <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <param name="FileNamePattern" value="${sonar.path.logs}/search.%i.log"/> - <param name="MinIndex" value="1"/> - <param name="MaxIndex" value="3"/> - </rollingPolicy> - <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <param name="MaxFileSize" value="5MB"/> - </triggeringPolicy> - <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> - <!-- Use %d{yyyy.MM.dd HH:mm:ss.SSS} to display milliseconds --> - <pattern> - %d{yyyy.MM.dd HH:mm:ss} %-5level [%logger{20}] %X %msg%n - </pattern> - </encoder> - </appender> - - <root> - <level value="INFO"/> - <appender-ref ref="LOGFILE"/> - </root> - -</configuration> diff --git a/server/sonar-process/pom.xml b/server/sonar-process/pom.xml index 457068b014c..d5ee17653b5 100644 --- a/server/sonar-process/pom.xml +++ b/server/sonar-process/pom.xml @@ -68,5 +68,40 @@ <artifactId>guava</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-process-test</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.8</version> + <executions> + <execution> + <id>copy</id> + <phase>process-test-resources</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-process-test</artifactId> + <version>${project.version}</version> + <type>jar</type> + <outputDirectory>${project.build.directory}/dummyApp</outputDirectory> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java index d1f4eff120d..460983290b0 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessWrapperTest.java @@ -20,6 +20,7 @@ package org.sonar.process; import org.junit.Before; +import org.junit.Test; import java.io.IOException; import java.net.ServerSocket; @@ -35,6 +36,13 @@ public class ProcessWrapperTest { socket.close(); } + + @Test + public void has_dummy_app(){ + + } + + // @Test // @Ignore("Not a good idea to assert on # of VMs") // public void process_should_run() throws IOException, MalformedObjectNameException, InterruptedException { |