Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright (C) 2016 Red Hat, Inc.
*
* <p>
* Licensed 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,24 +15,25 @@
*/
package io.fabric8.jenkins.openshiftsync;

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

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

/**
*
*/
public class BuildNameParseTest {
@Test
public void testParseBuildName() throws Exception {
assertBuildNameParse("job/cheese/123/", "cheese", "123");
assertBuildNameParse("/job/cheese/123/", "cheese", "123");
}
class BuildNameParseTest {

@Test
void testParseBuildName() {
assertBuildNameParse("job/cheese/123/", "cheese", "123");
assertBuildNameParse("/job/cheese/123/", "cheese", "123");
}

public static BuildName assertBuildNameParse(String url, String expectedJob, String expectedBuild) {
BuildName buildName = BuildName.parseBuildUrl(url);
assertEquals("Job name for url `" + url+ "`", expectedJob, buildName.getJobName());
assertEquals("Build name for url `" + url+ "`", expectedBuild, buildName.getBuildName());
return buildName;
}
private static void assertBuildNameParse(String url, String expectedJob, String expectedBuild) {
BuildName buildName = BuildName.parseBuildUrl(url);
assertEquals(expectedJob, buildName.getJobName(), "Job name for url `" + url + "`");
assertEquals(expectedBuild, buildName.getBuildName(), "Build name for url `" + url + "`");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
import com.cloudbees.workflow.rest.external.AtomFlowNodeExt;
import com.cloudbees.workflow.rest.external.RunExt;
import com.cloudbees.workflow.rest.external.StageNodeExt;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static io.fabric8.jenkins.openshiftsync.BuildSyncRunListener.asJSON;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class BuildSyncRunListenerTest {
class BuildSyncRunListenerTest {

@Test
void testRunExtToJSON() throws Exception {
StageNodeExt sn = new StageNodeExt();
sn.setStageFlowNodes(singletonList(new AtomFlowNodeExt()));
RunExt re = new RunExt();
re.setStages(singletonList(sn));
String json = asJSON(re);
assertFalse(json.contains("stageFlowNodes"), "json should not contain 'stageFlowNodes'");
}

@Test
public void testRunExtToJSON() throws Exception {
StageNodeExt sn = new StageNodeExt();
sn.setStageFlowNodes(singletonList(new AtomFlowNodeExt()));
RunExt re = new RunExt();
re.setStages(singletonList(sn));
String json = asJSON(re);
assertFalse("json should not contain 'stageFlowNodes'", json.contains("stageFlowNodes"));
}
}
39 changes: 20 additions & 19 deletions src/test/java/io/fabric8/jenkins/openshiftsync/JoinPathsTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright (C) 2016 Red Hat, Inc.
*
* <p>
* Licensed 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -15,25 +15,26 @@
*/
package io.fabric8.jenkins.openshiftsync;

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

import java.util.Arrays;

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

public class JoinPathsTest {
@Test
public void testJoinPaths() throws Exception {
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080/", "job/cheese/12/", "/wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080/", "/job/cheese/12/", "/wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080", "job/cheese/12/", "wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080", "job/cheese/12/", "wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080", "//job/cheese/12/", "wfapi/describe");
}
class JoinPathsTest {

private void assertJoinPaths(String expected, String... strings) {
String actual = BuildSyncRunListener.joinPaths(strings);
assertEquals("Join strings: " + Arrays.asList(strings), expected, actual);
}
@Test
void testJoinPaths() {
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080/", "job/cheese/12/", "/wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080/", "/job/cheese/12/", "/wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080", "job/cheese/12/", "wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080", "job/cheese/12/", "wfapi/describe");
assertJoinPaths("http://localhost:8080/job/cheese/12/wfapi/describe", "http://localhost:8080", "//job/cheese/12/", "wfapi/describe");
}

private static void assertJoinPaths(String expected, String... strings) {
String actual = BuildSyncRunListener.joinPaths(strings);
assertEquals(expected, actual, "Join strings: " + Arrays.asList(strings));
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
*/
package io.fabric8.jenkins.openshiftsync;

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

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

/**
*
*/
public class SafeKubernetesNameTest {
class SafeKubernetesNameTest {

@Test
public void testSafeNames() throws Exception {
void testSafeNames() {
assertSafeKubernetesName("Foo-Bar", "foo-bar");
assertSafeKubernetesName("-Foo-Bar", "foo-bar");
assertSafeKubernetesName(".-Foo-Bar", "foo-bar");
Expand All @@ -35,10 +37,10 @@ public void testSafeNames() throws Exception {
assertSafeKubernetesName("_*foo-bar/*wh!atnot)", "foo-bar.wh-atnot");
}

public static void assertSafeKubernetesName(String text, String expected) {
private static void assertSafeKubernetesName(String text, String expected) {
String actual = OpenShiftUtils.convertNameToValidResourceName(text);
//System.out.println("Converted `" + text + "` => `" + actual + "`");
assertEquals("Safe name for `" + text + "`", expected, actual);
assertEquals(expected, actual, "Safe name for `" + text + "`");
}

}
19 changes: 12 additions & 7 deletions systests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@

<dependencies>


<!-- system tests -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.1.11.Final</version>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
<version>1.9.3.Final</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -102,9 +101,15 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.12.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.12.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.assertj.core.api.Condition;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import static io.fabric8.kubernetes.assertions.Assertions.assertThat;

@RunWith(Arquillian.class)
public class JenkinsOpenShiftSysTest {
@ExtendWith(ArquillianExtension.class)
class JenkinsOpenShiftSysTest {

@ArquillianResource
KubernetesClient client;
private KubernetesClient client;

@ArquillianResource
Session session;
private Session session;

@Test
public void testAppProvisionsRunningPods() throws Exception {

void testAppProvisionsRunningPods() {
installInitialBuildConfigs();

assertThat(client).pods()
Expand Down