This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #47 from tobiasgindler/master
- Loading branch information
Showing
47 changed files
with
1,246 additions
and
1,131 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
85 changes: 85 additions & 0 deletions
85
...io/tracee/contextlogger/contextprovider/api/TraceeContextLoggerAbstractProcessorTest.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,85 @@ | ||
package io.tracee.contextlogger.contextprovider.api; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import javax.annotation.processing.Filer; | ||
import javax.lang.model.element.Element; | ||
import javax.tools.FileObject; | ||
import javax.tools.StandardLocation; | ||
import java.io.IOException; | ||
import java.io.Writer; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
import static org.mockito.Matchers.eq; | ||
import static org.mockito.Matchers.isNull; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* Unit test for {@link TraceeContextLoggerAbstractProcessor}. | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
public class TraceeContextLoggerAbstractProcessorTest { | ||
|
||
static final String GIVEN_FILE_NAME = "XXX"; | ||
|
||
@Mock | ||
Filer filer; | ||
|
||
@Before | ||
public void init() { | ||
TraceeContextLoggerAbstractProcessor.clearCache(); | ||
} | ||
|
||
@Test | ||
public void FileObjectWrapper_instantiationAndAppendTest() throws IOException { | ||
|
||
// prepare test | ||
FileObject fileObject = mock(FileObject.class); | ||
Writer writer = mock(Writer.class); | ||
when(fileObject.openWriter()).thenReturn(writer); | ||
|
||
TraceeContextLoggerAbstractProcessor.FileObjectWrapper fowUnit = new TraceeContextLoggerAbstractProcessor.FileObjectWrapper(fileObject); | ||
|
||
fowUnit.append("TEST"); | ||
|
||
verify(fileObject).openWriter(); | ||
verify(writer).append("TEST"); | ||
verify(writer).flush(); | ||
|
||
} | ||
|
||
@Test | ||
public void getOrcreateProfileProperties_createNewFileObject() throws IOException { | ||
|
||
FileObject fileObject = mock(FileObject.class); | ||
Writer writer = mock(Writer.class); | ||
|
||
when(filer.createResource(eq(StandardLocation.SOURCE_OUTPUT), eq(""), eq(GIVEN_FILE_NAME), isNull(Element.class))).thenReturn(fileObject); | ||
|
||
assertThat(TraceeContextLoggerAbstractProcessor.getOrCreateProfileProperties(filer, GIVEN_FILE_NAME), notNullValue()); | ||
verify(filer, times(1)).createResource(StandardLocation.SOURCE_OUTPUT, "", GIVEN_FILE_NAME, null); | ||
|
||
} | ||
|
||
@Test | ||
public void getOrcreateProfileProperties_getCachedFileObject() throws IOException { | ||
|
||
// fill cache | ||
getOrcreateProfileProperties_createNewFileObject(); | ||
|
||
// get it for the second time | ||
assertThat(TraceeContextLoggerAbstractProcessor.getOrCreateProfileProperties(filer, GIVEN_FILE_NAME), notNullValue()); | ||
verify(filer, times(1)).createResource(StandardLocation.SOURCE_OUTPUT, "", GIVEN_FILE_NAME, null); | ||
|
||
} | ||
|
||
|
||
} |
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
6 changes: 2 additions & 4 deletions
6
...ovider/api/src/main/java/io/tracee/contextlogger/contextprovider/api/ImplicitContext.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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
package io.tracee.contextlogger.contextprovider.api; | ||
|
||
/** | ||
* Defines all existing implicit contexts | ||
* Enums can be used to add implicit context providers to string representation output. | ||
* Created by Tobias Gindler, holisticon AG on 14.03.14. | ||
*/ | ||
public enum ImplicitContext { | ||
TRACEE, | ||
COMMON; | ||
public interface ImplicitContext { | ||
} |
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
Oops, something went wrong.