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
public class PersonRowMapper extends RowMapper<Person> { | |
@Override | |
public Person mapRow(ResultSet resultSet) throws SQLException { | |
Person person = new Person(); | |
person.setID(resultSet.getInt("ID")); | |
person.setFirstName(resultSet.getString("FIRSTNAME")); | |
return person; | |
} | |
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
*** Testcases *** | |
Grade Calculator | |
[Template] Calculate my grade | |
88 A | |
80 A | |
70 B | |
60 C | |
50 D | |
40 F |
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
public Person getPerson(int id) { | |
try { | |
String sql = "select * from person where id=?"; | |
JdbcTemplate<Person> jdbcTemplate = new JdbcTemplate<Person>(this.dataSource); | |
return jdbcTemplate.executeQueryObject(sql, new Object[] {id}, new PersonRowMapper()); | |
} catch (Exception e) { | |
throw new RetriveDataException("Cat not get all person"); | |
} | |
} |
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 attack_with_sql_injection_to_table_person_should_return_all_data() { | |
PersonDAO personDAO = new PersonDAO(getDataSource()); | |
List<Person> persons = personDAO.getPerson("'or '1'='1"); | |
assertEquals(5, persons.size()); | |
} |
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
<property name="cobertura.library.dir" value="cobertura_lib" /> | |
<property name="cobertura.dir" value="cobertura" /> | |
<property name="cobertura.instrumented.dir" value="${cobertura.dir}/instrumented" /> | |
<property name="cobertura.jar.file" value="${cobertura.library.dir}/cobertura-2.0.3.jar" /> | |
<path id="cobertura.classpath"> | |
<fileset dir="${cobertura.library.dir}"> | |
<include name="cobertura-2.0.3.jar" /> | |
<include name="*.jar" /> | |
</fileset> |
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
public void insert() throws Exception{ | |
try { | |
preparedStatement = connection.createPreparedStatement(sql); | |
preparedStatement.executeQuery(); | |
}catch(SQLException exception) { | |
throw new Exception( exception ); | |
} | |
} |
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
$curl -i "http://127.0.0.1:49162/buckets/test/keys/somkiat" -X PUT -H "Content-type: text/plain" -d "สวัสดี Riak" | |
HTTP/1.1 204 No Content | |
Vary: Accept-Encoding | |
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact) | |
Date: Tue, 09 Sep 2014 08:28:06 GMT | |
Content-Type: text/plain | |
Content-Length: 0 |
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
<?php | |
class OrderServiceUnitTest extends PHPUnit_Framework_TestCase { | |
private $mockOrderRepository; | |
private $mockEmailSender; | |
private $orderService; | |
function setUp() { | |
$this->mockOrderRepository = $this->getMock('OrderRepository'); | |
$this->mockEmailSender = $this->getMock('EmailSender'); |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import graphlab | |
graphlab.canvas.set_target('ipynb') | |
data = graphlab.SFrame.read_csv("http://s3.amazonaws.com/GraphLab-Datasets/movie_ratings/training_data.csv", column_type_hints={"rating":int}) | |
data.head() |
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
import lombok.experimental.Builder; | |
@Builder | |
public class Person { | |
private int id; | |
private String firstname; | |
private String lastname; | |
private double age; |