Skip to content

Commit

Permalink
Skip System.exit test for JDK > JDK 17.
Browse files Browse the repository at this point in the history
  • Loading branch information
VolkerHartmann committed Jun 28, 2023
1 parent 0631d4a commit 34588e9
Showing 1 changed file with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import org.springframework.web.context.WebApplicationContext;
import static com.github.stefanbirkner.systemlambda.SystemLambda.*;
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;

/**
*
* @author hartmann-v
Expand Down Expand Up @@ -106,7 +107,7 @@ public class ElasticIndexerRunnerTest {
private static Boolean alreadyInitialized = Boolean.FALSE;

private MockMvc mockMvc;

@Autowired
private ElasticIndexerRunner eir;
@Autowired
Expand All @@ -132,7 +133,6 @@ public class ElasticIndexerRunnerTest {
@Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();


private final static String TEMP_DIR_4_ALL = "/tmp/metastore2/elasticRunner/";
private final static String TEMP_DIR_4_SCHEMAS = TEMP_DIR_4_ALL + "schema/";
private final static String TEMP_DIR_4_METADATA = TEMP_DIR_4_ALL + "metadata/";
Expand Down Expand Up @@ -170,20 +170,20 @@ public class ElasticIndexerRunnerTest {

public ElasticIndexerRunnerTest() {
}

@BeforeClass
public static void setUpClass() {
}

@AfterClass
public static void tearDownClass() {
}

@Before
public void setUp() {
// setup mockMvc
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity())
.apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation).uris()
.withPort(41417))
.build();
Expand Down Expand Up @@ -223,18 +223,20 @@ public void setUp() {

}
}

@After
public void tearDown() {
}


@Test
public void testElasticRunnerWithWrongParameter() throws Exception {
int statusCode = catchSystemExit(() -> {
eir.run("hallo");
});
Assert.assertEquals(0, statusCode);
Integer mainVersion = Runtime.version().version().get(0);
if (mainVersion.compareTo(17) <= 0) {
int statusCode = catchSystemExit(() -> {
eir.run("hallo");
});
Assert.assertEquals(0, statusCode);
}
}

@Test
Expand Down Expand Up @@ -267,7 +269,6 @@ public void testElasticRunnerWithAllIndices() throws Exception {
Assert.assertTrue(true);
}


@Test
public void testElasticRunnerWithAllIndicesAndMetadataDocument() throws Exception {
String schemaLocation = ingestSchemaRecord("elastic2");
Expand All @@ -285,7 +286,7 @@ private String ingestSchemaRecord(String schemaId) throws Exception {
Set<AclEntry> aclEntries = new HashSet<>();
aclEntries.add(new AclEntry(AuthenticationHelper.ANONYMOUS_USER_PRINCIPAL, PERMISSION.READ));
schemaRecord.setAcl(aclEntries);

ObjectMapper mapper = new ObjectMapper();

MockMultipartFile recordFile = new MockMultipartFile("record", "record.json", "application/json", mapper.writeValueAsString(schemaRecord).getBytes());
Expand Down Expand Up @@ -314,12 +315,12 @@ private void ingestMetadataRecord(String schemaId) throws Exception {
* Ingest metadata with 'otheruser' set permissions for admin, user and guest.
*
* @param schemaId
* @param isUrl
* @param isUrl
* @throws Exception
*/
private void ingestMetadataRecord(String schemaId, boolean isUrl) throws Exception {
MetadataRecord record = new MetadataRecord();
if (isUrl) {
if (isUrl) {
record.setSchema(ResourceIdentifier.factoryUrlResourceIdentifier(schemaId));
} else {
record.setSchema(ResourceIdentifier.factoryInternalResourceIdentifier(schemaId));
Expand Down

0 comments on commit 34588e9

Please sign in to comment.