Navigation Menu

Skip to content

Commit

Permalink
ny pom.xmm a intergaces og annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
petchris committed Mar 5, 2021
1 parent fd87b5a commit 1fd4d1d
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 13 deletions.
Expand Up @@ -34,6 +34,7 @@
import java.util.List;
import java.util.Map;

import dk.netarkivet.common.utils.marker.FailsOnJenkins;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
Expand Down Expand Up @@ -74,6 +75,7 @@
import dk.netarkivet.testutils.TestMessageListener;
import dk.netarkivet.testutils.preconfigured.ReloadSettings;
import dk.netarkivet.testutils.preconfigured.UseTestRemoteFile;
import org.junit.experimental.categories.Category;

/**
* Unit tests for the class ArcRepositoryServer.
Expand Down Expand Up @@ -149,6 +151,7 @@ public void tearDown() throws Exception {
/**
* Test visit() StoreMessage methods arguments.
*/
@Category(FailsOnJenkins.class)
@Test
public void testVisitNulls() {
ArcRepository arc = ArcRepository.getInstance();
Expand Down Expand Up @@ -256,8 +259,9 @@ public void testVisitNulls() {
/**
* Test a BatchMessage is sent to the_bamon queue.
*/
//TODO seems to be no reason why this cannot be mocked by creating an ArcRepositoryServer with a mock
//ArcRepository .
// TODO seems to be no reason why this cannot be mocked by creating an ArcRepositoryServer with a mock
// ArcRepository.
@Category(FailsOnJenkins.class)
@Test
public void testVisitBatchMessage() {
// Create dummy server and listen on the TheArcrepos queue
Expand All @@ -280,6 +284,7 @@ public void testVisitBatchMessage() {
/**
* Test message is sent and returned, and set "Not OK" if an error occurs.
*/
@Category(FailsOnJenkins.class)
@Test
public void testStoreNoSuchFile() {
file = new File(BITARCHIVE_DIR, "NO_SUCH_FILE");
Expand Down Expand Up @@ -336,6 +341,7 @@ public void testStore() {
/**
* Test message is resent.
*/
@Category(FailsOnJenkins.class)
@Test
public void testGet() {
file = new File(BITARCHIVE_DIR, STORABLE_FILES.get(0).toString());
Expand All @@ -351,6 +357,7 @@ public void testGet() {
arc.close();
}

@Category(FailsOnJenkins.class)
@Test
public void testVisitBadMessages() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException,
InterruptedException {
Expand Down
Expand Up @@ -35,9 +35,10 @@
import java.util.Arrays;
import java.util.List;

import dk.netarkivet.common.utils.*;
import dk.netarkivet.common.utils.marker.FailsOnJenkins;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import dk.netarkivet.archive.ArchiveSettings;
Expand All @@ -55,16 +56,13 @@
import dk.netarkivet.common.distribute.RemoteFileFactory;
import dk.netarkivet.common.distribute.arcrepository.BitarchiveRecord;
import dk.netarkivet.common.exceptions.ArgumentNotValid;
import dk.netarkivet.common.utils.FileUtils;
import dk.netarkivet.common.utils.PrintNotifications;
import dk.netarkivet.common.utils.Settings;
import dk.netarkivet.common.utils.StreamUtils;
import dk.netarkivet.common.utils.batch.FileBatchJob;
import dk.netarkivet.testutils.FileAsserts;
import dk.netarkivet.testutils.MessageAsserts;
import dk.netarkivet.testutils.TestFileUtils;
import dk.netarkivet.testutils.preconfigured.ReloadSettings;
import dk.netarkivet.testutils.preconfigured.UseTestRemoteFile;
import org.junit.experimental.categories.Category;

/**
* Test bitarchive client and server As a number of tests only succeed if both the client and server both operate
Expand Down Expand Up @@ -195,6 +193,7 @@ public void testInvalidParams() {
/**
* Initiate upload and verify that corresponding upload message received by onUpload message handler.
*/
@Category(FailsOnJenkins.class)
@Test
public void testUpload() {
assertTrue("File to upload must exist: " + ARC_FILE_NAME, FILE_TO_UPLOAD.exists());
Expand All @@ -212,6 +211,7 @@ public void testUpload() {
/**
* Verify that it is possible to retrieve previously uploaded file.
*/
@Category(FailsOnJenkins.class)
@Test
public void testGetFile() {
assertTrue("File to upload must exist: " + ARC_FILE_NAME, FILE_TO_UPLOAD.exists());
Expand Down Expand Up @@ -243,6 +243,7 @@ public void testGetFile() {
* Try to upload the same file twice and verify that corresponding error message received by onUpload message
* handler.
*/
@Category(FailsOnJenkins.class)
@Test
public void testUploadTwice() {
Settings.set(CommonSettings.REMOTE_FILE_CLASS, "dk.netarkivet.common.distribute.TestRemoteFile");
Expand Down Expand Up @@ -276,6 +277,7 @@ public void testUploadTwice() {
*
* @throws IOException
*/
@Category(FailsOnJenkins.class)
@Test
public void testGet() throws IOException {
assertTrue("File to upload must exist: " + ARC_FILE_NAME, FILE_TO_UPLOAD.exists());
Expand Down Expand Up @@ -313,6 +315,7 @@ public void testGet() throws IOException {
* Test the batch(BatchMessage) method. Initiate batch job and verify that onBatch receives the corresponding
* message with correct result data from the batch job.
*/
@Category(FailsOnJenkins.class)
@Test
public void testBatch1() {
uploadInPreparationOfBatchTest();
Expand Down Expand Up @@ -348,6 +351,7 @@ public void testBatch2NullParameters() {
/**
* Verify that the batch(ChannelID,FileBatchJob,RemoteFile) method does not accept null parameters.
*/
@Category(FailsOnJenkins.class)
@Test
public void testBatch2() {
uploadInPreparationOfBatchTest();
Expand Down Expand Up @@ -404,6 +408,7 @@ private void verifyBatchWentWell() {
}
}

@Category(FailsOnJenkins.class)
@Test
public void testNewMessages() {
// make sure, that the listener 'handler' is the only one on the
Expand Down
Expand Up @@ -44,6 +44,7 @@
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;

import dk.netarkivet.common.utils.marker.FailsOnJenkins;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
Expand Down Expand Up @@ -88,6 +89,7 @@
import dk.netarkivet.testutils.preconfigured.PreventSystemExit;
import dk.netarkivet.testutils.preconfigured.ReloadSettings;
import dk.netarkivet.testutils.preconfigured.UseTestRemoteFile;
import org.junit.experimental.categories.Category;

/**
* Unit tests for the BitarchiveMonitorServer class.
Expand Down Expand Up @@ -149,6 +151,7 @@ public void tearDown() {
* Verify that batch jobs do not have to wait for each other. In particular, check that the postprocessing of one
* job can overtake the postprocessing of another.
*/
@Category(FailsOnJenkins.class)
@Test
public void testParallelBatchJobs() throws InterruptedException {
bam_server = BitarchiveMonitorServer.getInstance();
Expand Down Expand Up @@ -831,6 +834,7 @@ public void unstableTestGetAllFilenamesMessage() throws InterruptedException, IO
* Testing GetChecksumMessage.
* Requires file TestInfo.BATCH_ONE_CHECKSUM_OUTPUT_FILE
*/
@Category(FailsOnJenkins.class)
@Test
public void testGetChecksumMessage() throws InterruptedException, IOException {
assertTrue("Missing file '" + TestInfo.BATCH_ONE_CHECKSUM_OUTPUT_FILE.getAbsolutePath() + "' needed by RemoteFileFactory",
Expand Down Expand Up @@ -885,6 +889,7 @@ public void testGetChecksumMessage() throws InterruptedException, IOException {
* Tests the opportunity to correct a entry in the archive through CorrectMessage.
* Uses the file TestInfo.CORRECT_ARC_FILE and file TestInfo.BAD_ARC_FILE
*/
@Category(FailsOnJenkins.class)
@Test
public void testCorrectMessage() throws InterruptedException {
assertTrue("Missing file '" + TestInfo.CORRECT_ARC_FILE.getAbsolutePath() + "' needed by RemoteFileFactory", TestInfo.CORRECT_ARC_FILE.isFile());
Expand Down
Expand Up @@ -42,6 +42,8 @@
import javax.jms.Message;
import javax.jms.MessageListener;

import dk.netarkivet.common.utils.*;
import dk.netarkivet.common.utils.marker.FailsOnJenkins;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
Expand All @@ -64,10 +66,6 @@
import dk.netarkivet.common.distribute.TestRemoteFile;
import dk.netarkivet.common.exceptions.BatchTermination;
import dk.netarkivet.common.exceptions.IOFailure;
import dk.netarkivet.common.utils.FileUtils;
import dk.netarkivet.common.utils.RememberNotifications;
import dk.netarkivet.common.utils.Settings;
import dk.netarkivet.common.utils.SlowTest;
import dk.netarkivet.common.utils.batch.ChecksumJob;
import dk.netarkivet.testutils.ClassAsserts;
import dk.netarkivet.testutils.FileAsserts;
Expand Down Expand Up @@ -161,6 +159,7 @@ public void testLogging() throws IOException {
*
* @throws InterruptedException
*/
@Category(FailsOnJenkins.class)
@Test
public void testVisitUploadMessage() throws InterruptedException {
SERVER1.mkdirs();
Expand Down Expand Up @@ -231,6 +230,7 @@ public void testCTor() {
* <p>
* We currently don't resend the message, but just reply.
*/
@Category(FailsOnJenkins.class)
@Test
//@Ignore("Number of listeners on queue not 1.")
public void testVisitUploadMessageDiskcrash() {
Expand Down Expand Up @@ -279,6 +279,7 @@ public void testVisitUploadMessageDiskcrash() {
assertTrue("Should have received at least two messages on arcRepos q", listener.messagesReceived.size() >= 2);
}

@Category(FailsOnJenkins.class)
@Test
//@Ignore("Number of listeners on queue not 1.")
public void testListenerNotRemovedOnErrors() {
Expand Down Expand Up @@ -393,7 +394,7 @@ public void testVisitGetMessageNoSuchRecord() {
/**
* Pass a batch message to BitarchiveServer and test that it replies with an appropriate BatchEndedMessage.
*/
@Category(SlowTest.class) // This is actually not true, but the test fails if the other slowTest
@Category({SlowTest.class, FailsOnJenkins.class}) // This is actually not true, but the test fails if the other slowTest
// 'testVisitGetMessageNoSuchFile' hasn't run, and takes a long while to do this.
@Test
public void testVisitBatchMessage() throws InterruptedException {
Expand Down Expand Up @@ -541,7 +542,7 @@ public void initialize(OutputStream o) {
/**
* Test that a visit(RemoveAndGetMessage) call actually removes (moves) the file.
*/
@Category(SlowTest.class) // This is actually not true, but the test fails if the other slowTest
@Category({SlowTest.class, FailsOnJenkins.class }) // This is actually not true, but the test fails if the other slowTest
// 'testVisitGetMessageNoSuchFile' hasn't run, and takes a long while to do this.
@Test
public void testVisitRemoveAndGetFileMessage() throws Exception {
Expand Down
Expand Up @@ -33,6 +33,7 @@
import java.io.IOException;
import java.lang.reflect.Field;

import dk.netarkivet.common.utils.marker.FailsOnJenkins;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -46,6 +47,7 @@
import dk.netarkivet.testutils.TestFileUtils;
import dk.netarkivet.testutils.preconfigured.ReloadSettings;
import dk.netarkivet.testutils.preconfigured.UseTestRemoteFile;
import org.junit.experimental.categories.Category;

/**
* Tests for GetFileMessage
Expand All @@ -71,6 +73,7 @@ public void tearDown() {
rs.tearDown();
}

@Category(FailsOnJenkins.class)
@Test
public void testGetData() throws IOException, NoSuchFieldException, IllegalAccessException {
File origFile = new File(WORKING, "NetarchiveSuite-store1.arc");
Expand Down
Expand Up @@ -18,6 +18,7 @@

import dk.netarkivet.common.distribute.arcrepository.BitarchiveRecord;
import dk.netarkivet.common.utils.service.WarcRecordClient;
import org.junit.experimental.categories.Category;

public class WarcRecordClientTest {
final String WRS_URL = "https://localhost:10443/cgi-bin/warcrecordservice.cgi";
Expand Down Expand Up @@ -72,6 +73,7 @@ public void get() throws IOException, URISyntaxException {
System.out.println("\n\n" + IOUtils.toString(bitarchiveRecord.getData()));
}

@Category(FailsOnJenkins.class)
@Test
public void getWithArc() throws IOException, URISyntaxException {
URI baseUri = new URI(WRS_URL);
Expand Down
@@ -0,0 +1,4 @@
package dk.netarkivet.common.utils.marker;

public interface FailsOnJenkins {
}
@@ -0,0 +1,4 @@
package dk.netarkivet.common.utils.marker;

public interface FailsOnLocalAndJenkins {
}
30 changes: 30 additions & 0 deletions pom.xml
Expand Up @@ -917,6 +917,16 @@
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<!-- Read jUnit categories to be excluded from Maven property -->
<configuration>
<excludedGroups>${test.excluded.groups}</excludedGroups>
</configuration>
</plugin>

</plugins>
</pluginManagement>

Expand Down Expand Up @@ -1127,5 +1137,25 @@
</properties>
</profile>

<profile>
<!-- JenkinsUnitTest -->
<id>Default</id>
<!-- Set profile to be active by default -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<test.excluded.groups>dk.netarkivet.common.utils.marker.FailsOnJenkins</test.excluded.groups>
</properties>
</profile>
<profile>
<!-- Set profile to localUnitTest -->
<id>LocalUnitTest</id>
<properties>
<test.excluded.groups>dk.netarkivet.common.utils.FailsOnBoth</test.excluded.groups>
</properties>

</profile>

</profiles>
</project>

0 comments on commit 1fd4d1d

Please sign in to comment.