-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #363 from mesos/bug/357-ConfigurationNPE
Bug/357 configuration npe
- Loading branch information
Showing
8 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...test/java/org/apache/mesos/elasticsearch/scheduler/controllers/ClusterControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.apache.mesos.elasticsearch.scheduler.controllers; | ||
|
||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.SpringApplicationConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
|
||
/** | ||
* Test Cluster controller. | ||
*/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringApplicationConfiguration(classes = TestConfiguration.class) | ||
public class ClusterControllerTest { | ||
|
||
@Autowired | ||
private ClusterController clusterController; | ||
|
||
@Test | ||
public void shouldNotExceptionWhenGeneratingConfiguration() { | ||
clusterController.clusterInfo(); | ||
} | ||
|
||
@Test | ||
public void shouldNotHaveErrorInText() { | ||
clusterController.clusterInfo().configuration.values().forEach(v -> { | ||
assertFalse(v.toString().contains("ERROR")); | ||
}); | ||
} | ||
|
||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...src/test/java/org/apache/mesos/elasticsearch/scheduler/controllers/TestConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.apache.mesos.elasticsearch.scheduler.controllers; | ||
|
||
import org.apache.http.client.HttpClient; | ||
import org.apache.mesos.elasticsearch.common.cli.ZookeeperCLIParameter; | ||
import org.apache.mesos.elasticsearch.scheduler.ElasticsearchScheduler; | ||
import org.mockito.Mockito; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Test configuration for controllers | ||
*/ | ||
@EnableAutoConfiguration | ||
@ComponentScan | ||
@Configuration | ||
public class TestConfiguration { | ||
|
||
@Bean | ||
public ClusterController getClusterController() { | ||
return new ClusterController(); | ||
} | ||
|
||
@Bean | ||
public ElasticsearchScheduler getMockScheduler() { | ||
return Mockito.mock(ElasticsearchScheduler.class); | ||
} | ||
|
||
@Bean | ||
public org.apache.mesos.elasticsearch.scheduler.Configuration getConfig() { | ||
return new org.apache.mesos.elasticsearch.scheduler.Configuration(ZookeeperCLIParameter.ZOOKEEPER_MESOS_URL, "zk://dummy.mesos.master:2181"); | ||
} | ||
|
||
@Bean | ||
public HttpClient getMockHttpClient() { | ||
return Mockito.mock(HttpClient.class); | ||
} | ||
} |