Skip to content

Instantly share code, notes, and snippets.

Avatar

Dmitry Noranovich javaeeeee

View GitHub Profile
@javaeeeee
javaeeeee / HelloControllerTest.java
Created Feb 25, 2017
A Spring MVC REST controller test for a Spring Boot application
View HelloControllerTest.java
package com.javaeeeee.controllers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
@javaeeeee
javaeeeee / HelloControllerTest.java
Created Feb 25, 2017
A test for a Spring MVC REST Controller
View HelloControllerTest.java
package com.javaeeeee.springrest.controllers;
import org.junit.Test;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
@javaeeeee
javaeeeee / HelloController.java
Created Feb 25, 2017
An example Spring MVC REST controller
View HelloController.java
package com.javaeeeee.springrest.controllers;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String getGreeting() {
@javaeeeee
javaeeeee / dispatcher-servlet.xml
Created Feb 25, 2017
An example of Spring XML configuration file
View dispatcher-servlet.xml
<?xml version="1.0" encoding="windows-1252"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
@javaeeeee
javaeeeee / web.xml
Created Feb 25, 2017
An example of web.xml file with configured Spring DispatcherServlet
View web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
@javaeeeee
javaeeeee / tomcat-users.xml
Created Feb 25, 2017
A Tomcat configuration file
View tomcat-users.xml
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd">
<role rolename="manager-gui"/>
<user password="1" roles="manager-gui,manager-script,admin" username="admin"/>
</tomcat-users>
@javaeeeee
javaeeeee / pom.xml
Created Feb 25, 2017
A pom file for a simple Spring MVC application
View pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javaeeeee</groupId>
<artifactId>SpringREST</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpringREST Maven Webapp</name>
<url>http://maven.apache.org</url>
@javaeeeee
javaeeeee / index.html
Created Feb 6, 2017
AngularJS nested scopes Controller As syntax
View index.html
<section ng-controller="ParentController as parent">
<h4>Parent Scope</h4>
<p>{{parent.onlyParent}}</p>
<p>{{parent.myModel}}</p>
<article ng-controller="ChildController as child">
<h5>Child Scope</h5>
<p>{{child.onlyChild}}</p>
<p>{{child.myModel}}</p>
<p>{{parent.onlyParent}}</p>
<p>{{parent.myModel}}</p>
@javaeeeee
javaeeeee / hello.controller.spec.js
Created Feb 6, 2017
A test for an AngularJS controller that uses Controller As syntax. The test doesn't rely on AngularJS scope
View hello.controller.spec.js
describe('HelloController tests', function () {
var HelloController;
beforeEach(function () {
module('app');
inject(function ($controller) {
HelloController = $controller('HelloController');
});
@javaeeeee
javaeeeee / hello.controller.spec.js
Last active Feb 6, 2017
A test for an AngularJS controller that uses Controller As syntax relying on this syntax
View hello.controller.spec.js
describe('HelloController scope tests', function () {
var scope;
beforeEach(function () {
module('app');
inject(function ($rootScope, $controller) {
scope = $rootScope.$new();
$controller('HelloController as vm', { $scope: scope });
});
You can’t perform that action at this time.