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
class Foo { | |
private Helper helper = null; | |
public Helper synchronized getHelper() { | |
if (helper == null) | |
helper = new Helper(); | |
return helper; | |
} | |
} |
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
class Foo { | |
private Helper helper = null; | |
public Helper getHelper() { | |
if (helper == null) | |
helper = new Helper(); | |
return helper; | |
} | |
} |
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
private Long myNtfSeqNbrCounter = new Long(0); | |
private Long getNotificationSequenceNumber() { | |
Long result = null; | |
synchronized(myNtfSeqNbrCounter) { | |
result = new Long(myNtfSeqNbrCounter.longValue() + 1); | |
// ... | |
myNtfSeqNbrCounter = new Long(result.longValue()); | |
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
/** | |
* Manages statistic updates for a Runner in a load test. | |
*/ | |
public class WebRunnerStatsSender | |
{ | |
private final Map<String, VariableGroup> resourceToVariableGroup = new HashMap<>(); | |
private final Clock clock; | |
public WebRunnerStatsSender( Clock clock ) | |
{ |
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
/** | |
* Manages statistic updates for a Runner in a load test. | |
*/ | |
public class WebRunnerStatsSender | |
{ | |
private final Map<String, VariableGroup> resourceToVariableGroup = new HashMap<>(); | |
private final Clock clock; | |
public WebRunnerStatsSender( Clock clock ) | |
{ |
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
@Test | |
public void accessingNonExistentTest_should_fail() | |
{ | |
asList( "", "/assets", "/live-tabular-stats" ) | |
.forEach( this::assertPathYields404 ); | |
} | |
private void assertPathYields404( String path ) | |
{ | |
ClientResponse response = R.client().resource( ENDPOINT + "/"+ nonExistentId + path ) |
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
@Test | |
public void startingAndFetch() | |
{ | |
ClientResponse response = resources.client().resource( ENDPOINT ) | |
.type( MediaType.APPLICATION_JSON ) | |
.header( HttpHeaders.AUTHORIZATION, "Bearer DUMMYTOKEN" ) | |
.post( ClientResponse.class, dummyJson ); | |
assertThat( response.getStatus(), is( 201 ) ); | |
TestRun testRun = resources.client().resource( response.getLocation() ) |
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
@GET | |
@Path( "/{test}/assets" ) | |
@ApiOperation(value = "Returns all assets in a test run") | |
@ApiResponses(value = { | |
@ApiResponse(code = 404, message = "No test with given ID"), | |
}) | |
public String assets( @Auth User user, @PathParam( "test" ) String testId, @QueryParam( "scenario" ) String scenario ) | |
{ | |
TestRun testRun = testRunStorage.getTestRun( testId, user.getId() ) | |
.orElseThrow( () -> new WebApplicationException( NOT_FOUND ); |
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
package com.smartbear.saas.rs.storage; | |
import com.smartbear.saas.rs.model.TestRun; | |
import java.util.Optional; | |
import java.util.Set; | |
public interface TestRunStorage | |
{ | |
Optional<TestRun> getTest( String customerId, String testId ); |
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
@Before | |
public void setup() throws ComponentCreationException, IOException | |
{ | |
ctu = new ComponentTestUtils(); | |
ctu.getDefaultBeanInjectorMocker(); | |
component = ctu.createComponentItem(); | |
ComponentContext contextSpy = spy( component.getContext() ); | |
ctu.mockStatisticsFor( component, contextSpy ); |