Skip to content

Commit

Permalink
Merge branch 'openaire:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LSmyrnaios authored Jan 5, 2022
2 parents c542a45 + c27398c commit 9a6a5e0
Show file tree
Hide file tree
Showing 610 changed files with 13,163 additions and 9,870 deletions.
17 changes: 12 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ pipeline {
withEnv(["JAVA_HOME=${ tool type: 'jdk', name: "$JDK_VERSION" }",
"PATH+MAVEN=${tool type: 'maven', name: "$MAVEN_VERSION"}/bin:${env.JAVA_HOME}/bin"]) {
withSonarQubeEnv('sonar.ceon.pl') {
//NOTE: sonar scan is only done for master branch because current Sonar instance does not support branching
sh '''
mvn clean package \
-DskipITs \
-Djava.net.preferIPv4Stack=true \
$SONAR_MAVEN_GOAL \
-Dsonar.host.url=$SONAR_HOST_URL
if [ $GIT_BRANCH = "master" ]; then
mvn clean package \
-DskipITs \
-Djava.net.preferIPv4Stack=true \
$SONAR_MAVEN_GOAL \
-Dsonar.host.url=$SONAR_HOST_URL
else
mvn clean package \
-DskipITs \
-Djava.net.preferIPv4Stack=true
fi
'''
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
/**
* Copyright (c) 2013, Cloudera, Inc. All Rights Reserved.
*
* Cloudera, Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"). You may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for
* the specific language governing permissions and limitations under the
* License.
*/
package com.cloudera.science.avro.common;

import static org.junit.Assert.assertEquals;

import java.util.Arrays;

import com.google.common.collect.ImmutableList;
import org.apache.avro.Schema;
import org.apache.avro.Schema.Type;
import org.apache.avro.generic.GenericRecord;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.google.common.collect.ImmutableList;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class JsonConverterTest {

Expand Down Expand Up @@ -63,12 +49,12 @@ public void testBasicWithRecord() throws Exception {
GenericRecord r = jc.convert(json);
assertEquals(json, r.toString());
}
@Test(expected=IllegalArgumentException.class)
public void testMissingRequiredField() throws Exception {

@Test
public void testMissingRequiredField() {
JsonConverter jc = new JsonConverter(sr(f1, f2, f3Rec));
String json = "{\"field2\": [true, true, false], \"field3\": {\"key\": \"value\"}}";
jc.convert(json);
assertThrows(IllegalArgumentException.class, () -> jc.convert(json));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
package org.apache.avro.io;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.avro.AvroTypeException;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.HackedJsonDecoder;
import org.apache.avro.io.HackedJsonEncoder;
import org.junit.Test;

import org.apache.avro.io.schemas.Document;
import org.apache.avro.io.schemas.PersonEntry;
import org.apache.avro.io.schemas.PersonWithDocument;
import org.junit.jupiter.api.Test;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

/**
* @author Mateusz Kobos
Expand Down Expand Up @@ -123,9 +116,8 @@ private void checkJsonReadWrite(String jsonInput, Schema schema,
}
}
if (shouldThrowParsingException) {
assertTrue(
"This code should not have been reached because of previous "
+ "exception thrown", false);
fail("This code should not have been reached because of previous "
+ "exception thrown");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ def brackets(elts):

# replace @ w/ "__obj", but \@ means a literal @
loc = re.sub(r'(?<!\\)@', "__obj", loc).replace(r'\@', '@')
if not use_eval:
if debug: print "eval disabled"
raise Exception("eval disabled")
if debug: print "eval", loc
#if not use_eval:
# if debug: print "eval disabled"
# raise Exception("eval disabled")
#if debug: print "eval", loc
try:
# eval w/ caller globals, w/ local "__obj"!
v = eval(loc, caller_globals, {'__obj': obj})
Expand Down
6 changes: 6 additions & 0 deletions iis-build/iis-build-properties-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package eu.dnetlib.maven.plugin.properties;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static eu.dnetlib.maven.plugin.properties.GenerateOoziePropertiesMojo.PROPERTY_NAME_SANDBOX_NAME;
import static eu.dnetlib.maven.plugin.properties.GenerateOoziePropertiesMojo.PROPERTY_NAME_WF_SOURCE_DIR;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import org.junit.Before;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
* @author mhorst
Expand All @@ -16,7 +16,7 @@ public class GenerateOoziePropertiesMojoTest {

private GenerateOoziePropertiesMojo mojo = new GenerateOoziePropertiesMojo();

@Before
@BeforeEach
public void clearSystemProperties() {
System.clearProperty(PROPERTY_NAME_SANDBOX_NAME);
System.clearProperty(PROPERTY_NAME_WF_SOURCE_DIR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,44 @@
package eu.dnetlib.maven.plugin.properties;

import static eu.dnetlib.maven.plugin.properties.WritePredefinedProjectProperties.PROPERTY_PREFIX_ENV;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

import java.io.*;
import java.util.Properties;

import static eu.dnetlib.maven.plugin.properties.WritePredefinedProjectProperties.PROPERTY_PREFIX_ENV;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.lenient;


/**
* @author mhorst
*
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class WritePredefinedProjectPropertiesTest {

@Rule
public TemporaryFolder testFolder = new TemporaryFolder();
@TempDir
public File testFolder;

@Mock
private MavenProject mavenProject;

private WritePredefinedProjectProperties mojo;

@Before
@BeforeEach
public void init() {
mojo = new WritePredefinedProjectProperties();
mojo.outputFile = getPropertiesFileLocation();
mojo.project = mavenProject;
doReturn(new Properties()).when(mavenProject).getProperties();
lenient().doReturn(new Properties()).when(mavenProject).getProperties();
}

// ----------------------------------- TESTS ---------------------------------------------
Expand Down Expand Up @@ -80,19 +73,19 @@ public void testExecuteWithProjectProperties() throws Exception {
assertTrue(storedProperties.containsKey(key));
assertEquals(value, storedProperties.getProperty(key));
}
@Test(expected=MojoExecutionException.class)
public void testExecuteWithProjectPropertiesAndInvalidOutputFile() throws Exception {

@Test
public void testExecuteWithProjectPropertiesAndInvalidOutputFile() {
// given
String key = "projectPropertyKey";
String value = "projectPropertyValue";
Properties projectProperties = new Properties();
projectProperties.setProperty(key, value);
doReturn(projectProperties).when(mavenProject).getProperties();
mojo.outputFile = testFolder.getRoot();
mojo.outputFile = testFolder;

// execute
mojo.execute();
assertThrows(MojoExecutionException.class, () -> mojo.execute());
}

@Test
Expand Down Expand Up @@ -154,8 +147,8 @@ public void testExecuteIncludingPropertyKeysFromFile() throws Exception {
projectProperties.setProperty(key, value);
projectProperties.setProperty(includedKey, includedValue);
doReturn(projectProperties).when(mavenProject).getProperties();
File includedPropertiesFile = new File(testFolder.getRoot(), "included.properties");

File includedPropertiesFile = new File(testFolder, "included.properties");
Properties includedProperties = new Properties();
includedProperties.setProperty(includedKey, "irrelevantValue");
includedProperties.store(new FileWriter(includedPropertiesFile), null);
Expand Down Expand Up @@ -197,9 +190,9 @@ public void testExecuteIncludingPropertyKeysFromClasspathResource() throws Excep
assertTrue(storedProperties.containsKey(includedKey));
assertEquals(includedValue, storedProperties.getProperty(includedKey));
}
@Test(expected=MojoExecutionException.class)
public void testExecuteIncludingPropertyKeysFromBlankLocation() throws Exception {

@Test
public void testExecuteIncludingPropertyKeysFromBlankLocation() {
// given
String key = "projectPropertyKey";
String value = "projectPropertyValue";
Expand All @@ -213,7 +206,7 @@ public void testExecuteIncludingPropertyKeysFromBlankLocation() throws Exception
mojo.setIncludePropertyKeysFromFiles(new String[] {""});

// execute
mojo.execute();
assertThrows(MojoExecutionException.class, () -> mojo.execute());
}

@Test
Expand All @@ -227,8 +220,8 @@ public void testExecuteIncludingPropertyKeysFromXmlFile() throws Exception {
projectProperties.setProperty(key, value);
projectProperties.setProperty(includedKey, includedValue);
doReturn(projectProperties).when(mavenProject).getProperties();
File includedPropertiesFile = new File(testFolder.getRoot(), "included.xml");

File includedPropertiesFile = new File(testFolder, "included.xml");
Properties includedProperties = new Properties();
includedProperties.setProperty(includedKey, "irrelevantValue");
includedProperties.storeToXML(new FileOutputStream(includedPropertiesFile), null);
Expand All @@ -245,8 +238,8 @@ public void testExecuteIncludingPropertyKeysFromXmlFile() throws Exception {
assertTrue(storedProperties.containsKey(includedKey));
assertEquals(includedValue, storedProperties.getProperty(includedKey));
}
@Test(expected=MojoExecutionException.class)

@Test
public void testExecuteIncludingPropertyKeysFromInvalidXmlFile() throws Exception {
// given
String key = "projectPropertyKey";
Expand All @@ -257,16 +250,16 @@ public void testExecuteIncludingPropertyKeysFromInvalidXmlFile() throws Exceptio
projectProperties.setProperty(key, value);
projectProperties.setProperty(includedKey, includedValue);
doReturn(projectProperties).when(mavenProject).getProperties();
File includedPropertiesFile = new File(testFolder.getRoot(), "included.xml");

File includedPropertiesFile = new File(testFolder, "included.xml");
Properties includedProperties = new Properties();
includedProperties.setProperty(includedKey, "irrelevantValue");
includedProperties.store(new FileOutputStream(includedPropertiesFile), null);

mojo.setIncludePropertyKeysFromFiles(new String[] {includedPropertiesFile.getAbsolutePath()});

// execute
mojo.execute();
assertThrows(MojoExecutionException.class, () -> mojo.execute());
}

@Test
Expand All @@ -283,14 +276,14 @@ public void testExecuteWithQuietModeOn() throws Exception {
Properties storedProperties = getStoredProperties();
assertEquals(0, storedProperties.size());
}
@Test(expected=MojoExecutionException.class)
public void testExecuteIncludingPropertyKeysFromInvalidFile() throws Exception {

@Test
public void testExecuteIncludingPropertyKeysFromInvalidFile() {
// given
mojo.setIncludePropertyKeysFromFiles(new String[] {"invalid location"});

// execute
mojo.execute();
assertThrows(MojoExecutionException.class, () -> mojo.execute());
}

@Test
Expand Down Expand Up @@ -354,7 +347,7 @@ public void testExecuteWithSystemPropertiesAndEscapeChars() throws Exception {
// ----------------------------------- PRIVATE -------------------------------------------

private File getPropertiesFileLocation() {
return new File(testFolder.getRoot(), "test.properties");
return new File(testFolder, "test.properties");
}

private Properties getStoredProperties() throws FileNotFoundException, IOException {
Expand Down
2 changes: 1 addition & 1 deletion iis-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>eu.dnetlib.iis.common.IntegrationTest</excludedGroups>
<excludedGroups>IntegrationTest,${otherExcludedGroups}</excludedGroups>
</configuration>
</plugin>

Expand Down
Loading

0 comments on commit 9a6a5e0

Please sign in to comment.