本文整理汇总了Java中org.testng.internal.collections.Pair类的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pair类属于org.testng.internal.collections包,在下文中一共展示了Pair类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: load
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Override
public Pair<String, String> load(String userId) throws Exception
{
String clientId = prefix + userId;
String uuid = null;
JsonNode results = requests.list().get("results");
for( JsonNode jsonNode : results )
{
JsonNode clientIdNode = jsonNode.get("clientId");
if( clientId.equals(clientIdNode.asText()) )
{
uuid = jsonNode.get("uuid").asText();
break;
}
}
if( uuid == null )
{
uuid = requests.createClient(clientId, adminPassword, userId, "default");
}
return new Pair<String, String>(clientId, uuid);
}
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:OAuthTokenCache.java
示例2: testUpdateProfileThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when updating profile",
dependsOnMethods = {"testUpdateProfileThrowingFeatureManagerDAOException"},
expectedExceptions = IllegalTransactionStateException.class)
public void testUpdateProfileThrowingIllegalTransactionStateException() throws Exception {
//Retrieving profile object
Profile savedProfile = profileManager.getProfile(profile1.getProfileId());
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.first()).setAutoCommit(anyBoolean());
String newProfileName = "Updated Test Profile";
savedProfile.setProfileName(newProfileName);
try {
profileManager.updateProfile(savedProfile);
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:19,代码来源:ProfileManagerImplTest.java
示例3: testAddProfileThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when adding new profile feature",
dependsOnMethods = "testAddProfileFeatureThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testAddProfileThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_D);
ProfileFeature profileFeature = profile.getProfileFeaturesList().get(0);
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.first()).setAutoCommit(anyBoolean());
try {
featureManager.addProfileFeature(profileFeature, profile.getProfileId());
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:17,代码来源:FeatureManagerImplTest.java
示例4: testAddProfileFeaturesThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when adding new profile feature",
dependsOnMethods = "testAddProfileFeaturesThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testAddProfileFeaturesThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_D);
List<ProfileFeature> profileFeaturesList = profile.getProfileFeaturesList();
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.first()).setAutoCommit(anyBoolean());
try {
featureManager.addProfileFeatures(profileFeaturesList, profile.getProfileId());
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:17,代码来源:FeatureManagerImplTest.java
示例5: testUpdateProfileFeaturesThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when adding new profile feature",
dependsOnMethods = "testUpdateProfileFeaturesThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testUpdateProfileFeaturesThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_D);
List<ProfileFeature> profileFeaturesList = profile.getProfileFeaturesList();
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.first()).setAutoCommit(anyBoolean());
try {
featureManager.updateProfileFeatures(profileFeaturesList, profile.getProfileId());
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:17,代码来源:FeatureManagerImplTest.java
示例6: mockConnection
import org.testng.internal.collections.Pair; //导入依赖的package包/类
protected Pair<Connection, Pair<DataSource, DataSource>> mockConnection() throws Exception {
//Throwing PolicyManagerDAOException while adding profile
DatabaseMetaData databaseMetaData = mock(DatabaseMetaData.class);
when(databaseMetaData.getDatabaseProductName()).thenReturn("H2");
Connection conn = mock(Connection.class);
when(conn.getMetaData()).thenReturn(databaseMetaData);
DataSource dataSource = mock(DataSource.class);
when(dataSource.getConnection()).thenReturn(conn);
Field dataSourceField = PolicyManagementDAOFactory.class.getDeclaredField("dataSource");
dataSourceField.setAccessible(true);
DataSource oldDataSource = (DataSource) dataSourceField.get(null);
PolicyManagementDAOFactory.init(dataSource);
return new Pair<>(conn, new Pair<>(oldDataSource, dataSource));
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:19,代码来源:BasePolicyManagementDAOTest.java
示例7: invalidate
import org.testng.internal.collections.Pair; //导入依赖的package包/类
public void invalidate(String userId)
{
Pair<String, String> clientInfo = clientCache.getIfPresent(userId);
if( clientInfo != null )
{
requests.delete(clientInfo.second());
clientCache.invalidate(userId);
tokenMap.invalidate(userId);
}
}
开发者ID:equella,项目名称:Equella,代码行数:11,代码来源:OAuthTokenCache.java
示例8: testAddProfileThrowingPolicyComplianceException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling PolicyComplianceException when checking policy compliance",
dependsOnMethods = "testCheckPolicyComplianceThrowingProfileManagerDAOException",
expectedExceptions = PolicyComplianceException.class)
public void testAddProfileThrowingPolicyComplianceException() throws Exception {
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doAnswer(new Answer<Connection>() {
int callCounter = 0;
@Override
public Connection answer(InvocationOnMock invocationOnMock) throws Throwable {
if(callCounter > 0){
Field currentConnectionField = PolicyManagementDAOFactory.class.getDeclaredField("currentConnection");
currentConnectionField.setAccessible(true);
ThreadLocal<Connection> threadLocal = new ThreadLocal<>();
threadLocal.set(pair.first());
currentConnectionField.set(null, threadLocal);
throw new SQLException();
}
callCounter++;
return pair.second().first().getConnection();
}
}).when(pair.second().second()).getConnection();
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setType(DEVICE_TYPE_E);
deviceIdentifier.setId(String.valueOf(device5.getDeviceIdentifier()));
try {
monitoringManager.checkPolicyCompliance(deviceIdentifier, new ArrayList<ComplianceFeature>());
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:31,代码来源:MonitoringManagerImplTest.java
示例9: testIsCompliantThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when checking is compliant",
dependsOnMethods = "testIsCompliantThrowingMonitoringDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testIsCompliantThrowingIllegalTransactionStateException() throws Exception {
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setType(DEVICE_TYPE_E);
deviceIdentifier.setId(String.valueOf(device5.getDeviceIdentifier()));
monitoringManager.isCompliant(deviceIdentifier);
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:16,代码来源:MonitoringManagerImplTest.java
示例10: testAddProfileThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when adding new profile",
dependsOnMethods = "testAddProfileThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testAddProfileThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Profile profile = ProfileCreator.getProfile(FeatureCreator.getFeatureList(), DEVICE_TYPE_C);
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.first()).setAutoCommit(anyBoolean());
try {
profileManager.addProfile(profile);
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:15,代码来源:ProfileManagerImplTest.java
示例11: testGetProfileThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when retrieving profile",
dependsOnMethods = "testGetProfileThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testGetProfileThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
profileManager.getProfile(profile1.getProfileId());
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:15,代码来源:ProfileManagerImplTest.java
示例12: testGetAllProfilesThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when retrieving all profiles",
dependsOnMethods = "testGetAllProfilesThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testGetAllProfilesThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
profileManager.getAllProfiles();
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:15,代码来源:ProfileManagerImplTest.java
示例13: testGetProfilesOfDeviceTypeThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when retrieving all profiles of a device type",
dependsOnMethods = "testGetProfilesOfDeviceTypeThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testGetProfilesOfDeviceTypeThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
profileManager.getProfilesOfDeviceType(DEVICE_TYPE_C);
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:15,代码来源:ProfileManagerImplTest.java
示例14: testDeleteProfileThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when deleting a profile",
dependsOnMethods = "testDeleteProfileThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testDeleteProfileThrowingIllegalTransactionStateException() throws Exception {
//Creating profile object
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
profileManager.deleteProfile(profile1);
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:15,代码来源:ProfileManagerImplTest.java
示例15: testGetAllFeaturesThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when all features of a device type",
dependsOnMethods = "testGetAllFeatures",
expectedExceptions = {IllegalTransactionStateException.class, FeatureManagementException.class})
public void testGetAllFeaturesThrowingIllegalTransactionStateException() throws Exception {
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
featureManager.getAllFeatures(DEVICE_TYPE_D);
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:13,代码来源:FeatureManagerImplTest.java
示例16: testGetFeaturesForProfileThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when retrieving features of a profile",
dependsOnMethods = "testGetFeaturesForProfileThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testGetFeaturesForProfileThrowingIllegalTransactionStateException() throws Exception {
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
featureManager.getFeaturesForProfile(profile1.getProfileId());
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:13,代码来源:FeatureManagerImplTest.java
示例17: testDeleteFeaturesOfProfileThrowingIllegalTransactionStateException
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test(description = "This test case tests handling SQLException when deleting features of a profile",
dependsOnMethods = "testDeleteFeaturesOfProfileThrowingFeatureManagerDAOException",
expectedExceptions = IllegalTransactionStateException.class)
public void testDeleteFeaturesOfProfileThrowingIllegalTransactionStateException() throws Exception {
Pair<Connection, Pair<DataSource, DataSource>> pair = mockConnection();
PowerMockito.doThrow(new SQLException()).when(pair.second().second()).getConnection();
try {
featureManager.deleteFeaturesOfProfile(profile1);
} finally {
PolicyManagementDAOFactory.init(pair.second().first());
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:13,代码来源:FeatureManagerImplTest.java
示例18: testMoveToTrash
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test
public void testMoveToTrash() throws IOException {
TrashTestBase trash = new TrashTestBase(new Properties());
Path pathToDelete = new Path("/path/to/delete");
final List<Pair<Path, Path>> movedPaths = Lists.newArrayList();
when(trash.fs.exists(any(Path.class))).thenReturn(false);
when(trash.fs.rename(any(Path.class), any(Path.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation)
throws Throwable {
Object[] args = invocation.getArguments();
movedPaths.add(new Pair<Path, Path>((Path) args[0], (Path) args[1]));
return true;
}
});
Assert.assertTrue(trash.trash.moveToTrash(pathToDelete));
verify(trash.fs, times(1)).mkdirs(any(Path.class));
Assert.assertEquals(movedPaths.size(), 1);
Assert.assertTrue(movedPaths.get(0).first().equals(pathToDelete));
Assert.assertTrue(movedPaths.get(0).second().toString().endsWith(pathToDelete.toString()));
Assert.assertTrue(movedPaths.get(0).second().getParent().getParent().getParent().equals(trash.trash.getTrashLocation()));
}
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:31,代码来源:TrashTest.java
示例19: testMoveToTrashExistingFile
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test
public void testMoveToTrashExistingFile() throws IOException {
TrashTestBase trash = new TrashTestBase(new Properties());
String fileName = "delete";
Path pathToDelete = new Path("/path/to", fileName);
Pattern expectedNamePattern = Pattern.compile("^" + fileName + "_[0-9]+$");
final List<Pair<Path, Path>> movedPaths = Lists.newArrayList();
when(trash.fs.exists(any(Path.class))).thenReturn(true);
when(trash.fs.rename(any(Path.class), any(Path.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation)
throws Throwable {
Object[] args = invocation.getArguments();
movedPaths.add(new Pair<Path, Path>((Path) args[0], (Path) args[1]));
return true;
}
});
Assert.assertTrue(trash.trash.moveToTrash(pathToDelete));
verify(trash.fs, times(0)).mkdirs(any(Path.class));
Assert.assertEquals(movedPaths.size(), 1);
Assert.assertTrue(movedPaths.get(0).first().equals(pathToDelete));
Assert.assertTrue(movedPaths.get(0).second().getParent().toString().endsWith(pathToDelete.getParent().toString()));
Assert.assertTrue(expectedNamePattern.matcher(movedPaths.get(0).second().getName()).matches());
Assert.assertTrue(movedPaths.get(0).second().getParent().getParent().getParent().equals(trash.trash.getTrashLocation()));
}
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:35,代码来源:TrashTest.java
示例20: checkTerminalTypingCharsWithoutShift
import org.testng.internal.collections.Pair; //导入依赖的package包/类
@Test
public void checkTerminalTypingCharsWithoutShift() {
loader.waitOnClosed();
terminal.selectTerminalTab();
terminal.waitTerminalConsole();
terminal.waitTerminalIsNotEmpty();
for (Pair<String, String> pair : keyPairs) {
terminal.typeIntoTerminal(pair.first());
terminal.waitExpectedTextIntoTerminal("$ " + pair.first());
terminal.typeIntoTerminal(Keys.BACK_SPACE.toString());
}
}
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:TerminalTypingTest.java
注:本文中的org.testng.internal.collections.Pair类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论