-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renaming FreeMaker* and Freemaker* to Freemarker* and blocking access…
… to all routes page when in production environment
- Loading branch information
1 parent
a9aaf44
commit c7c2cae
Showing
4 changed files
with
99 additions
and
36 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
54 changes: 54 additions & 0 deletions
54
src/test/java/br/com/caelum/vraptor/dash/monitor/RoutesControllerTest.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,54 @@ | ||
package br.com.caelum.vraptor.dash.monitor; | ||
|
||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Matchers.anyString; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
|
||
import br.com.caelum.vraptor.environment.Environment; | ||
import br.com.caelum.vraptor.freemarker.Freemarker; | ||
import br.com.caelum.vraptor.freemarker.Template; | ||
import br.com.caelum.vraptor.http.MutableRequest; | ||
import br.com.caelum.vraptor.http.route.Router; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class RoutesControllerTest { | ||
|
||
private @Mock Router router; | ||
private @Mock MutableRequest request; | ||
private @Mock Freemarker marker; | ||
private @Mock Template indexTemplate; | ||
private @Mock Environment environment; | ||
|
||
private RoutesController controller; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
this.controller = new RoutesController(router, request, marker, environment); | ||
|
||
when(marker.use("routes/index")).thenReturn(indexTemplate); | ||
when(indexTemplate.with(anyString(), any())).thenReturn(indexTemplate); | ||
} | ||
|
||
@Test | ||
public void showsAllRegisteredRoutesWhenAccessedOutOfProductionEnvironment() throws Exception { | ||
when(environment.getName()).thenReturn("notProduction"); | ||
|
||
controller.allRoutes(); | ||
|
||
verify(router).allRoutes(); | ||
} | ||
|
||
@Test(expected=UnsupportedOperationException.class) | ||
public void throwsExceptionWhenAccessedInProductionEnvironment() throws Exception { | ||
when(environment.getName()).thenReturn("production"); | ||
|
||
controller.allRoutes(); | ||
} | ||
} |