+++ /dev/null
-#!/bin/sh
-
-mvn clean install -DskipTests -pl :sonar-server,:sonar-search,:sonar-process -amd
-
-if [[ "$OSTYPE" == "darwin"* ]]; then
- OS='macosx-universal-64'
-else
- OS='linux-x86-64'
-fi
-
-cd sonar-application/target/
-if ! ls sonarqube-*/bin/$OS/sonar.sh &> /dev/null; then
- unzip sonarqube-*.zip
-fi
-
-cd sonarqube-*
-touch logs/application.log
-touch logs/search.log
-touch logs/sonar.log
-
-tmux new-session "tmux split-window -v 'tail -f logs/sonar.log'; tmux split-window -h 'tail -f logs/search.log'; java -jar lib/sonar-application*.jar -Dsonar.node.name=forky"
-#tmux new-session "tmux split-window -h 'tail -f logs/search.log'; java -jar lib/sonar-application*.jar"
-
-#tmux new-session "tmux split-window -v 'tail -f logs/sonar.log'; tmux split-window -h 'tail -f logs/search.log'; tail -f logs/application.log"
<artifactId>sonar-testing-harness</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<artifactId>sonar-xoo-plugin</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<pluginClass>org.sonar.plugins.cpd.CpdPlugin</pluginClass>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
<pluginClass>org.sonar.plugins.dbcleaner.DbCleanerPlugin</pluginClass>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
</project>
<pluginDescription><![CDATA[Language pack for English]]></pluginDescription>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
<?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/maven-v4_0_0.xsd">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.sonar</groupId>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
+ <skipBatchTests>false</skipBatchTests>
+ <skipServerTests>false</skipServerTests>
+ <skipWebTests>false</skipWebTests>
+
<!-- To configure animal-sniffer to check API compat -->
<animal-sniffer.signature.groupId>org.codehaus.mojo.signature</animal-sniffer.signature.groupId>
<animal-sniffer.signature.artifactId>java16</animal-sniffer.signature.artifactId>
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
<pluginExecution>
</goals>
</pluginExecutionFilter>
<action>
- <ignore />
+ <ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</plugins>
</build>
</profile>
+
+
+ <!--
+ The following profiles optimize the build for each team, according to their
+ stack layers (batch, server and web teams)
+ -->
+ <profile>
+ <!-- disable all tests -->
+ <id>skipTests</id>
+ <activation>
+ <property>
+ <name>skipTests</name>
+ </property>
+ </activation>
+ <properties>
+ <skipWebTests>true</skipWebTests>
+ <skipBatchTests>true</skipBatchTests>
+ <skipServerTests>true</skipServerTests>
+ </properties>
+ </profile>
+ <profile>
+ <id>batch</id>
+ <properties>
+ <skipServerTests>true</skipServerTests>
+ <skipWebTests>true</skipWebTests>
+ </properties>
+ </profile>
+ <profile>
+ <id>server</id>
+ <properties>
+ <skipBatchTests>true</skipBatchTests>
+ <skipWebTests>true</skipWebTests>
+ </properties>
+ </profile>
+ <profile>
+ <id>web</id>
+ <properties>
+ <!-- the web team does not care about java tests -->
+ <skipBatchTests>true</skipBatchTests>
+ <skipServerTests>true</skipServerTests>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
</profiles>
</project>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+
</plugins>
</build>
</project>
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(ConfigurationUtils.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(ConfigurationUtils.class)).isTrue();
}
}
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(LoopbackAddress.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(LoopbackAddress.class)).isTrue();
}
}
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(NetworkUtils.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(NetworkUtils.class)).isTrue();
}
}
import org.junit.Test;
import org.sonar.test.TestUtils;
+import static org.fest.assertions.Assertions.assertThat;
+
public class ProcessUtilsTest {
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(ProcessUtils.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(ProcessUtils.class)).isTrue();
}
}
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
<id>js-tests</id>
<activation>
<property>
- <name>!skipTests</name>
+ <name>skipWebTests</name>
+ <value>false</value>
</property>
</activation>
<build>
</archive>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
</plugins>
</build>
<profiles>
@Test
public void private_constructor() throws Exception {
- TestUtils.assertPrivateConstructor(DefaultSettings.class);
+ assertThat(TestUtils.hasOnlyPrivateConstructors(DefaultSettings.class)).isTrue();
}
}
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
</dependency>
<!-- unit tests -->
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipServerTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipBatchTests}</skipTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
</dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<artifactId>hamcrest-all</artifactId>
</dependency>
<dependency>
- <!-- used only for org.sonar.test.channel classes -->
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-channel</artifactId>
- <optional>true</optional>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <version>${project.version}</version>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.server.ws;
import java.lang.reflect.Modifier;
import java.net.URL;
-import static org.fest.assertions.Assertions.assertThat;
-import static org.fest.assertions.Fail.fail;
-
/**
* Utilities for unit tests
*
return getResource(resourcePath);
}
- public static void assertPrivateConstructor(Class clazz) {
- try {
- Constructor constructor = clazz.getDeclaredConstructor();
- assertThat(Modifier.isPrivate(constructor.getModifiers())).isTrue();
- constructor.setAccessible(true);
- constructor.newInstance();
- } catch (Exception e) {
- fail("Fail to instantiate " + clazz, e);
+ /**
+ * Asserts that all constructors are private, usually for helper classes with
+ * only static methods. If a constructor does not have any parameters, then
+ * it's instantiated.
+ */
+ public static boolean hasOnlyPrivateConstructors(Class clazz) {
+ boolean ok = true;
+ for (Constructor constructor : clazz.getDeclaredConstructors()) {
+ ok &= Modifier.isPrivate(constructor.getModifiers());
+ if (constructor.getParameterTypes().length == 0) {
+ constructor.setAccessible(true);
+ try {
+ constructor.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException(String.format("Fail to instantiate %s", clazz), e);
+ }
+ }
}
+ return ok;
}
}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * 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.test.channel;
-
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.sonar.channel.Channel;
-import org.sonar.channel.CodeReader;
-
-public class ChannelMatcher<O> extends BaseMatcher<Channel<O>> {
-
- private final String sourceCode;
- private final O output;
- private final CodeReader reader;
-
- public ChannelMatcher(String sourceCode, O output) {
- this.sourceCode = sourceCode;
- this.output = output;
- this.reader = new CodeReader(sourceCode);
- }
-
- public ChannelMatcher(CodeReader reader, O output) {
- this.output = output;
- this.sourceCode = new String(reader.peek(30));
- this.reader = reader;
- }
-
- public boolean matches(Object arg0) {
- if ( !(arg0 instanceof Channel)) {
- return false;
- }
- Channel<O> channel = (Channel<O>) arg0;
- return channel.consume(reader, output);
- }
-
- public void describeTo(Description description) {
- description.appendText("Channel consumes '" + sourceCode + "'");
- }
-
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * 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.test.channel;
-
-import org.sonar.channel.CodeReader;
-
-public final class ChannelMatchers {
-
- private ChannelMatchers() {
- }
-
- public static <O> ChannelMatcher<O> consume(String sourceCode, O output) {
- return new ChannelMatcher<O>(sourceCode, output);
- }
-
- public static <O> ChannelMatcher<O> consume(CodeReader codeReader, O output) {
- return new ChannelMatcher<O>(codeReader, output);
- }
-
- public static ReaderHasNextCharMatcher hasNextChar(char nextChar) {
- return new ReaderHasNextCharMatcher(nextChar);
- }
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * 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.test.channel;
-
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.sonar.channel.CodeReader;
-
-public class ReaderHasNextCharMatcher extends BaseMatcher<CodeReader> {
-
- private final char nextChar;
-
- public ReaderHasNextCharMatcher(char nextChar) {
- this.nextChar = nextChar;
- }
-
- public boolean matches(Object arg0) {
- if ( !(arg0 instanceof CodeReader)) {
- return false;
- }
- CodeReader reader = (CodeReader) arg0;
- return reader.peek() == nextChar;
- }
-
- public void describeTo(Description description) {
- description.appendText("next char is '" + nextChar + "'");
- }
-
-}
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.test.channel;
-
-import javax.annotation.ParametersAreNonnullByDefault;
import org.sonar.test.TestUtils;
import java.io.File;
+import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
* Checks that all the translation bundles found on the classpath are up to date with the corresponding default ones found in the classpath.
*/
public static void assertBundlesUpToDate() {
- File bundleFolder = TestUtils.getResource(BundleSynchronizedMatcher.L10N_PATH);
+ File bundleFolder = getResource(BundleSynchronizedMatcher.L10N_PATH);
if (bundleFolder == null || !bundleFolder.isDirectory()) {
fail("No bundle found in: " + BundleSynchronizedMatcher.L10N_PATH);
}
fail(message.toString());
}
}
+
+ private static File getResource(String path) {
+ String resourcePath = path;
+ if (!resourcePath.startsWith("/")) {
+ resourcePath = "/" + resourcePath;
+ }
+ URL url = TestUtils.class.getResource(resourcePath);
+ if (url != null) {
+ return FileUtils.toFile(url);
+ }
+ return null;
+ }
}
import java.io.File;
import static org.fest.assertions.Assertions.assertThat;
+import static org.fest.assertions.Fail.fail;
import static org.sonar.test.TestUtils.getResource;
public class TestUtilsTest {
File file = getResource("org/sonar/test/TestUtilsTest/unknown.txt");
assertThat(file).isNull();
}
+
+ @Test
+ public void hasOnlyPrivateConstructors() {
+ assertThat(TestUtils.hasOnlyPrivateConstructors(TestUtils.class)).isTrue();
+ assertThat(TestUtils.hasOnlyPrivateConstructors(OnlyPrivateConstructors.class)).isTrue();
+ assertThat(TestUtils.hasOnlyPrivateConstructors(MixOfPublicAndPrivateConstructors.class)).isFalse();
+ try {
+ TestUtils.hasOnlyPrivateConstructors(FailToInstantiate.class);
+ fail();
+ } catch (IllegalStateException e) {
+ // ok
+ }
+ }
+
+ public static class OnlyPrivateConstructors {
+ private OnlyPrivateConstructors() {
+ }
+
+ private OnlyPrivateConstructors(int i) {
+ }
+
+ public static void foo() {
+
+ }
+ }
+
+ public static class MixOfPublicAndPrivateConstructors {
+ private MixOfPublicAndPrivateConstructors() {
+ }
+
+ public MixOfPublicAndPrivateConstructors(int i) {
+ }
+
+ public static void foo() {
+
+ }
+ }
+
+ public static class FailToInstantiate {
+ private FailToInstantiate() {
+ throw new IllegalArgumentException();
+ }
+ }
}