2 * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * - Neither the name of the Git Development Community nor the
19 * names of its contributors may be used to endorse or promote
20 * products derived from this software without specific prior
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 package org
.spearce
.jgit
.lib
;
40 import java
.util
.Date
;
41 import java
.util
.TimeZone
;
43 import junit
.framework
.TestCase
;
45 public class T0001_PersonIdent
extends TestCase
{
46 public void test001_NewIdent() {
47 final PersonIdent p
= new PersonIdent("A U Thor", "author@example.com",
48 new Date(1142878501000L), TimeZone
.getTimeZone("EST"));
49 assertEquals("A U Thor", p
.getName());
50 assertEquals("author@example.com", p
.getEmailAddress());
51 assertEquals(1142878501000L, p
.getWhen().getTime());
52 assertEquals("A U Thor <author@example.com> 1142878501 -0500", p
56 public void test002_ParseIdent() {
57 final String i
= "A U Thor <author@example.com> 1142878501 -0500";
58 final PersonIdent p
= new PersonIdent(i
);
59 assertEquals(i
, p
.toExternalString());
60 assertEquals("A U Thor", p
.getName());
61 assertEquals("author@example.com", p
.getEmailAddress());
62 assertEquals(1142878501000L, p
.getWhen().getTime());
65 public void test003_ParseIdent() {
66 final String i
= "A U Thor <author@example.com> 1142878501 +0230";
67 final PersonIdent p
= new PersonIdent(i
);
68 assertEquals(i
, p
.toExternalString());
69 assertEquals("A U Thor", p
.getName());
70 assertEquals("author@example.com", p
.getEmailAddress());
71 assertEquals(1142878501000L, p
.getWhen().getTime());
74 public void test004_ParseIdent() {
75 final String i
= "A U Thor<author@example.com> 1142878501 +0230";
76 final PersonIdent p
= new PersonIdent(i
);
77 assertEquals("A U Thor", p
.getName());
78 assertEquals("author@example.com", p
.getEmailAddress());
79 assertEquals(1142878501000L, p
.getWhen().getTime());
82 public void test005_ParseIdent() {
83 final String i
= "A U Thor<author@example.com>1142878501 +0230";
84 final PersonIdent p
= new PersonIdent(i
);
85 assertEquals("A U Thor", p
.getName());
86 assertEquals("author@example.com", p
.getEmailAddress());
87 assertEquals(1142878501000L, p
.getWhen().getTime());
90 public void test006_ParseIdent() {
91 final String i
= "A U Thor <author@example.com>1142878501 +0230";
92 final PersonIdent p
= new PersonIdent(i
);
93 assertEquals("A U Thor", p
.getName());
94 assertEquals("author@example.com", p
.getEmailAddress());
95 assertEquals(1142878501000L, p
.getWhen().getTime());
98 public void test007_ParseIdent() {
99 final String i
= "A U Thor<author@example.com>1142878501 +0230 ";
100 final PersonIdent p
= new PersonIdent(i
);
101 assertEquals("A U Thor", p
.getName());
102 assertEquals("author@example.com", p
.getEmailAddress());
103 assertEquals(1142878501000L, p
.getWhen().getTime());