2011-08-07 20:51:53 +10:00
|
|
|
Java Faker
|
|
|
|
|
==========
|
2013-12-24 09:30:26 +11:00
|
|
|
|
2015-07-09 13:06:18 +10:00
|
|
|
[](http://mvnrepository.com/artifact/com.github.javafaker/javafaker)
|
2016-04-25 22:53:05 +02:00
|
|
|
[](https://travis-ci.org/DiUS/java-faker)
|
|
|
|
|
[](https://coveralls.io/r/DiUS/java-faker)
|
2016-05-06 15:43:51 +10:00
|
|
|
[](http://www.apache.org/licenses/LICENSE-2.0.html)
|
2014-04-23 12:47:43 +10:00
|
|
|
|
2018-03-15 11:37:19 +00:00
|
|
|
This library is a port of Ruby's [faker](https://github.com/stympy/faker) gem (as well as Perl's Data::Faker library) that generates fake data.
|
2011-08-07 22:09:59 +10:00
|
|
|
It's useful when you're developing a new project and need some pretty data for showcase.
|
2011-08-07 20:51:53 +10:00
|
|
|
|
|
|
|
|
Usage
|
|
|
|
|
-----
|
2016-10-16 18:35:47 -04:00
|
|
|
In pom.xml, add the following xml stanza between `<dependencies> ... </dependencies>`
|
2012-02-21 23:25:47 +11:00
|
|
|
|
2012-02-21 23:23:47 +11:00
|
|
|
```xml
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>com.github.javafaker</groupId>
|
|
|
|
|
<artifactId>javafaker</artifactId>
|
2020-02-11 19:52:30 +11:00
|
|
|
<version>1.0.2</version>
|
2016-10-16 18:35:47 -04:00
|
|
|
</dependency>
|
|
|
|
|
```
|
|
|
|
|
|
2015-12-07 08:48:02 +11:00
|
|
|
For gradle users, add the following to your build.gradle file.
|
|
|
|
|
|
|
|
|
|
```groovy
|
|
|
|
|
dependencies {
|
2020-02-11 19:52:30 +11:00
|
|
|
implementation 'com.github.javafaker:javafaker:1.0.2'
|
2015-12-07 08:48:02 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
2012-02-21 23:23:47 +11:00
|
|
|
In your Java code
|
2012-02-21 23:25:47 +11:00
|
|
|
|
2011-08-07 21:09:59 +10:00
|
|
|
```java
|
|
|
|
|
Faker faker = new Faker();
|
2011-08-07 20:51:53 +10:00
|
|
|
|
2014-04-23 17:24:34 +10:00
|
|
|
String name = faker.name().fullName(); // Miss Samanta Schmidt
|
|
|
|
|
String firstName = faker.name().firstName(); // Emory
|
|
|
|
|
String lastName = faker.name().lastName(); // Barton
|
2011-08-07 20:51:53 +10:00
|
|
|
|
2014-04-24 14:52:13 +10:00
|
|
|
String streetAddress = faker.address().streetAddress(); // 60018 Sawayn Brooks Suite 449
|
2011-08-07 21:09:59 +10:00
|
|
|
```
|
2011-08-07 20:51:53 +10:00
|
|
|
|
2019-07-20 21:03:15 +10:00
|
|
|
This is a [demo web application](https://java-faker.herokuapp.com/) that uses the library.
|
|
|
|
|
|
2016-04-09 20:51:31 +02:00
|
|
|
Javadoc
|
|
|
|
|
-----
|
|
|
|
|
http://dius.github.io/java-faker/apidocs/index.html
|
|
|
|
|
|
2016-04-20 02:31:52 -03:00
|
|
|
|
2019-07-20 12:41:03 +10:00
|
|
|
Contributions
|
|
|
|
|
-------------
|
|
|
|
|
See [CONTRIBUTING.md](https://github.com/DiUS/java-faker/blob/master/CONTRIBUTING.md)
|
|
|
|
|
|
|
|
|
|
|
2016-04-20 02:31:52 -03:00
|
|
|
Fakers
|
|
|
|
|
-----
|
2019-08-28 08:40:11 -04:00
|
|
|
* Address
|
2016-12-18 00:57:17 +01:00
|
|
|
* Ancient
|
2019-05-22 08:22:40 +02:00
|
|
|
* Animal
|
2016-04-25 07:32:57 +10:00
|
|
|
* App
|
2019-08-28 08:40:11 -04:00
|
|
|
* Aqua Teen Hunger Force
|
2017-03-12 22:33:40 +01:00
|
|
|
* Artist
|
2017-12-16 17:38:35 -07:00
|
|
|
* Avatar
|
2019-06-25 15:47:38 +01:00
|
|
|
* Back To The Future
|
2019-07-05 19:10:24 +03:00
|
|
|
* Aviation
|
2020-05-09 01:40:56 +08:00
|
|
|
* Basketball
|
2016-04-26 12:19:08 +10:00
|
|
|
* Beer
|
2020-05-09 01:29:59 +08:00
|
|
|
* Bojack Horseman
|
2016-04-20 02:31:52 -03:00
|
|
|
* Book
|
2016-04-25 22:08:51 +10:00
|
|
|
* Bool
|
2016-04-20 02:31:52 -03:00
|
|
|
* Business
|
2016-04-28 22:58:33 +02:00
|
|
|
* ChuckNorris
|
2016-06-03 03:48:21 +03:00
|
|
|
* Cat
|
2016-04-20 02:31:52 -03:00
|
|
|
* Code
|
2020-03-14 19:55:16 +02:00
|
|
|
* Coin
|
2016-04-20 02:31:52 -03:00
|
|
|
* Color
|
2016-04-25 07:32:57 +10:00
|
|
|
* Commerce
|
2016-04-20 02:31:52 -03:00
|
|
|
* Company
|
2016-04-30 05:09:52 +02:00
|
|
|
* Crypto
|
2016-04-20 02:31:52 -03:00
|
|
|
* DateAndTime
|
2017-03-12 22:31:10 +01:00
|
|
|
* Demographic
|
2020-05-09 01:58:31 +08:00
|
|
|
* Disease
|
2018-08-12 17:20:02 -07:00
|
|
|
* Dog
|
2018-05-23 18:02:33 -06:00
|
|
|
* DragonBall
|
2019-08-15 11:04:01 -04:00
|
|
|
* Dune
|
2016-04-29 20:19:20 +02:00
|
|
|
* Educator
|
2017-05-19 12:14:12 +02:00
|
|
|
* Esports
|
2020-11-09 01:05:23 +09:00
|
|
|
* EnglandFootBall
|
2016-11-16 23:22:56 +01:00
|
|
|
* File
|
2016-04-20 02:31:52 -03:00
|
|
|
* Finance
|
2016-10-23 01:16:05 +02:00
|
|
|
* Food
|
2017-05-22 00:25:13 +02:00
|
|
|
* Friends
|
2018-05-23 18:02:33 -06:00
|
|
|
* FunnyName
|
2016-11-16 23:23:13 +01:00
|
|
|
* GameOfThrones
|
2020-05-15 09:56:18 +08:00
|
|
|
* Gender
|
2016-04-25 07:32:57 +10:00
|
|
|
* Hacker
|
2017-05-18 05:15:03 +02:00
|
|
|
* HarryPotter
|
2017-05-25 01:49:23 +02:00
|
|
|
* Hipster
|
2018-05-23 18:02:33 -06:00
|
|
|
* HitchhikersGuideToTheGalaxy
|
|
|
|
|
* Hobbit
|
|
|
|
|
* HowIMetYourMother
|
2016-05-04 22:43:26 +02:00
|
|
|
* IdNumber
|
2016-04-20 02:31:52 -03:00
|
|
|
* Internet
|
2017-05-25 01:34:26 +02:00
|
|
|
* Job
|
2020-02-20 22:36:46 +01:00
|
|
|
* Kaamelott
|
2018-05-23 18:02:33 -06:00
|
|
|
* LeagueOfLegends
|
2018-03-27 05:45:54 -04:00
|
|
|
* Lebowski
|
2017-05-18 05:15:03 +02:00
|
|
|
* LordOfTheRings
|
2016-04-20 02:31:52 -03:00
|
|
|
* Lorem
|
2017-06-01 08:07:09 +02:00
|
|
|
* Matz
|
2016-11-16 23:32:16 +01:00
|
|
|
* Music
|
2016-04-20 02:31:52 -03:00
|
|
|
* Name
|
2019-08-14 15:03:21 -04:00
|
|
|
* Nation
|
2016-04-20 02:31:52 -03:00
|
|
|
* Number
|
|
|
|
|
* Options
|
2018-05-23 18:02:33 -06:00
|
|
|
* Overwatch
|
2016-04-20 02:31:52 -03:00
|
|
|
* PhoneNumber
|
2020-04-20 10:44:44 +03:00
|
|
|
* Photography
|
2016-11-23 06:59:10 +01:00
|
|
|
* Pokemon
|
2019-06-25 15:47:38 +01:00
|
|
|
* Princess Bride
|
2019-07-23 16:11:08 -04:00
|
|
|
* Relationship Terms
|
2017-05-31 02:21:00 +02:00
|
|
|
* RickAndMorty
|
2018-05-23 18:02:33 -06:00
|
|
|
* Robin
|
2017-05-19 07:50:04 +02:00
|
|
|
* RockBand
|
2016-04-29 20:52:15 +02:00
|
|
|
* Shakespeare
|
2020-08-03 00:02:35 +03:00
|
|
|
* Sip
|
2016-11-23 07:00:38 +01:00
|
|
|
* SlackEmoji
|
2016-11-17 22:31:54 +01:00
|
|
|
* Space
|
2020-04-12 09:51:15 -07:00
|
|
|
* StarCraft
|
2018-05-23 18:02:33 -06:00
|
|
|
* StarTrek
|
2016-12-02 01:43:36 +01:00
|
|
|
* Stock
|
2016-04-25 11:26:26 +10:00
|
|
|
* Superhero
|
2016-04-25 08:24:16 +02:00
|
|
|
* Team
|
2017-05-25 07:36:47 +02:00
|
|
|
* TwinPeaks
|
2016-05-01 10:45:12 +10:00
|
|
|
* University
|
2018-02-15 01:32:17 +02:00
|
|
|
* Weather
|
2017-09-25 00:17:26 +02:00
|
|
|
* Witcher
|
2017-05-30 05:42:09 +02:00
|
|
|
* Yoda
|
2017-05-18 05:15:03 +02:00
|
|
|
* Zelda
|
2016-04-20 02:31:52 -03:00
|
|
|
|
|
|
|
|
Usage with Locales
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
|
|
```java
|
2018-02-01 09:30:45 +11:00
|
|
|
Faker faker = new Faker(new Locale("YOUR_LOCALE"));
|
2016-04-20 02:31:52 -03:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Supported Locales
|
|
|
|
|
-----
|
2017-05-22 00:36:55 +02:00
|
|
|
* bg
|
2016-04-20 02:31:52 -03:00
|
|
|
* ca
|
|
|
|
|
* ca-CAT
|
|
|
|
|
* da-DK
|
|
|
|
|
* de
|
|
|
|
|
* de-AT
|
|
|
|
|
* de-CH
|
|
|
|
|
* en
|
|
|
|
|
* en-AU
|
|
|
|
|
* en-au-ocker
|
|
|
|
|
* en-BORK
|
|
|
|
|
* en-CA
|
|
|
|
|
* en-GB
|
|
|
|
|
* en-IND
|
2017-10-27 14:24:34 +02:00
|
|
|
* en-MS
|
2016-04-20 02:31:52 -03:00
|
|
|
* en-NEP
|
2017-03-16 21:31:03 +01:00
|
|
|
* en-NG
|
2016-04-20 02:31:52 -03:00
|
|
|
* en-NZ
|
2017-03-16 21:31:03 +01:00
|
|
|
* en-PAK
|
2016-04-20 02:31:52 -03:00
|
|
|
* en-SG
|
|
|
|
|
* en-UG
|
|
|
|
|
* en-US
|
2017-03-16 21:31:03 +01:00
|
|
|
* en-ZA
|
2016-04-20 02:31:52 -03:00
|
|
|
* es
|
2017-03-16 21:31:03 +01:00
|
|
|
* es-MX
|
2016-04-20 02:31:52 -03:00
|
|
|
* fa
|
|
|
|
|
* fi-FI
|
|
|
|
|
* fr
|
|
|
|
|
* he
|
2019-09-09 18:51:07 +02:00
|
|
|
* hu
|
2017-03-16 21:31:03 +01:00
|
|
|
* in-ID
|
2016-04-20 02:31:52 -03:00
|
|
|
* it
|
|
|
|
|
* ja
|
|
|
|
|
* ko
|
|
|
|
|
* nb-NO
|
|
|
|
|
* nl
|
|
|
|
|
* pl
|
|
|
|
|
* pt
|
|
|
|
|
* pt-BR
|
|
|
|
|
* ru
|
|
|
|
|
* sk
|
|
|
|
|
* sv
|
2017-03-16 21:31:03 +01:00
|
|
|
* sv-SE
|
|
|
|
|
* tr
|
2016-04-20 02:31:52 -03:00
|
|
|
* uk
|
|
|
|
|
* vi
|
|
|
|
|
* zh-CN
|
|
|
|
|
* zh-TW
|
|
|
|
|
|
2016-04-11 22:53:59 +10:00
|
|
|
TODO
|
|
|
|
|
----
|
2016-04-29 11:14:37 +10:00
|
|
|
- Port more classes over as there are more entries in the yml file that we don't have classes for
|
2014-04-22 12:08:32 +10:00
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
|
-------
|
2019-05-11 12:56:45 +10:00
|
|
|
Copyright (c) 2019 DiUS Computing Pty Ltd. See the LICENSE file for license rights and limitations.
|