1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.core.server.test.internal.session;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import org.eclipse.osee.framework.core.server.internal.session.Session;
import org.eclipse.osee.framework.core.server.internal.session.SessionFactory;
import org.eclipse.osee.framework.core.server.test.mocks.MockBuildTypeIdentifier;
import org.eclipse.osee.framework.core.server.test.mocks.MockLog;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
/**
* Test Case for {@link Session}
*
* @author Roberto E. Escobar
*/
@RunWith(Parameterized.class)
public class SessionFactoryTest {
private final String guid;
private final String userId;
private final Date creationDate;
private final String clientVersion;
private final String clientMachineName;
private final String clientAddress;
private final int clientPort;
private final MockBuildTypeIdentifier typeIdentifier = new MockBuildTypeIdentifier();
private final SessionFactory factory = new SessionFactory(new MockLog(), null, typeIdentifier);
public SessionFactoryTest(String guid, String userId, Date creationDate, String clientVersion, String clientMachineName, String clientAddress, int clientPort) {
super();
this.guid = guid;
this.userId = userId;
this.creationDate = creationDate;
this.clientVersion = clientVersion;
this.clientMachineName = clientMachineName;
this.clientAddress = clientAddress;
this.clientPort = clientPort;
}
@Test
public void testCreate() {
Session session =
factory.createNewSession(guid, userId, creationDate, clientVersion, clientMachineName, clientAddress,
clientPort);
Assert.assertEquals(guid, session.getGuid());
Assert.assertEquals(userId, session.getUserId());
Assert.assertEquals(creationDate, session.getCreationDate());
Assert.assertEquals(clientVersion, session.getClientVersion());
Assert.assertEquals(clientMachineName, session.getClientMachineName());
Assert.assertEquals(clientAddress, session.getClientAddress());
Assert.assertEquals(clientPort, session.getClientPort());
}
@Parameters
public static Collection<Object[]> getData() {
Collection<Object[]> data = new ArrayList<Object[]>();
for (int index = 1; index <= 3; index++) {
String guid = "ABCD" + String.valueOf(index);
String clientAddress = "addresss-" + index;
String clientMachine = "machine-" + index;
String clientVersion = "version-" + index;
int clientPort = index * 345;
Date creationDate = new Date();
String userId = "hello.userId-" + index;
data.add(new Object[] {guid, userId, creationDate, clientVersion, clientMachine, clientAddress, clientPort
});
}
return data;
}
}
|