TAS-188 add autowired capability and parallel execution

This commit is contained in:
Paul Brodner
2016-08-04 14:58:19 +03:00
parent d3507fa904
commit 19c7436c36
4 changed files with 72 additions and 33 deletions

View File

@@ -0,0 +1,30 @@
package org.alfresco.rest;
import org.alfresco.rest.v1.Sites;
import org.alfresco.tester.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.testng.Assert;
import org.testng.annotations.Test;
public class SampleATest extends BaseRestTest
{
@Autowired
Sites onSites;
@Test
public void sampleATestMethod1()
{
UserModel admin = new UserModel("admin", "admin");
Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites");
}
@Test
public void sampleATestMethod2()
{
UserModel admin = new UserModel("admin", "a");
Assert.assertTrue(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites");
Assert.assertEquals(onSites.usingRestWrapper().getLastStatus().getName(), HttpStatus.ACCEPTED.name(), "Status Code Name");
}
}

View File

@@ -0,0 +1,31 @@
package org.alfresco.rest;
import org.alfresco.rest.v1.Sites;
import org.alfresco.tester.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.testng.Assert;
import org.testng.annotations.Test;
public class SampleBTest extends BaseRestTest
{
@Autowired
Sites onSites;
@Test
public void sampleBTestMethod1()
{
UserModel admin = new UserModel("admin", "admin");
Assert.assertFalse(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites");
}
@Test
public void sampleBTestMethod2()
{
UserModel admin = new UserModel("admin", "a");
Assert.assertTrue(onSites.withAuthUser(admin).getSites().getEntries().isEmpty(), "We have sites");
Assert.assertEquals(onSites.usingRestWrapper().getLastStatus().getName().toLowerCase(), HttpStatus.UNAUTHORIZED.name().toLowerCase(), "Status Code Name");
}
}

View File

@@ -1,33 +0,0 @@
package org.alfresco.rest.v1;
import static org.alfresco.rest.RestWrapper.onRestAPI;
import java.io.IOException;
import org.alfresco.rest.BaseRestTest;
import org.alfresco.tester.model.UserModel;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
public class SitesTest extends BaseRestTest
{
@Test
public void getSite()
{
UserModel admin = new UserModel("admin", "admin");
System.out.println(onRestAPI().withAuthUser(admin).onSites().getSite("SiteName1470151654495").getTitle());
}
@Test
public void getSites() throws JsonParseException, JsonMappingException, IOException
{
UserModel admin = new UserModel("admin", "admin");
Assert.assertEquals(onRestAPI().withAuthUser(admin).onSites().getSites().getPagination().getTotalItems(), 281);
Assert.assertEquals(onRestAPI().withAuthUser(admin).onSites().getSites().getEntries().get(0).onModel().getTitle(), "0-C2291-1470255221170");
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="classes">
<test name="Test">
<classes>
<class name="org.alfresco.rest.SampleATest"></class>
<class name="org.alfresco.rest.SampleBTest"></class>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->