-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Argument parsing moved to the main class. Argument validation now throw exception. More tests added for config factory. Created unit tests for JmxScraper class.
- Loading branch information
Showing
7 changed files
with
217 additions
and
104 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/ArgumentsParsingException.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,10 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.contrib.jmxscraper; | ||
|
||
public class ArgumentsParsingException extends Exception { | ||
private static final long serialVersionUID = 0L; | ||
} |
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
39 changes: 39 additions & 0 deletions
39
jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/JmxScraperTest.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 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.contrib.jmxscraper; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import io.opentelemetry.contrib.jmxscraper.config.JmxScraperConfigFactory; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class JmxScraperTest { | ||
@Test | ||
void shouldThrowExceptionWhenInvalidCommandLineArgsProvided() { | ||
// Given | ||
List<String> emptyArgs = Collections.singletonList("-inexistingOption"); | ||
JmxScraperConfigFactory configFactoryMock = mock(JmxScraperConfigFactory.class); | ||
|
||
// When and Then | ||
assertThatThrownBy(() -> JmxScraper.createConfigFromArgs(emptyArgs, configFactoryMock)) | ||
.isInstanceOf(ArgumentsParsingException.class); | ||
} | ||
|
||
@Test | ||
void shouldThrowExceptionWhenTooManyCommandLineArgsProvided() { | ||
// Given | ||
List<String> emptyArgs = Arrays.asList("-config", "path", "-inexistingOption"); | ||
JmxScraperConfigFactory configFactoryMock = mock(JmxScraperConfigFactory.class); | ||
|
||
// When and Then | ||
assertThatThrownBy(() -> JmxScraper.createConfigFromArgs(emptyArgs, configFactoryMock)) | ||
.isInstanceOf(ArgumentsParsingException.class); | ||
} | ||
} |
Oops, something went wrong.