當前位置: 首頁>>代碼示例>>Java>>正文


Java ArquillianResource類代碼示例

本文整理匯總了Java中org.jboss.arquillian.test.api.ArquillianResource的典型用法代碼示例。如果您正苦於以下問題:Java ArquillianResource類的具體用法?Java ArquillianResource怎麽用?Java ArquillianResource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ArquillianResource類屬於org.jboss.arquillian.test.api包,在下文中一共展示了ArquillianResource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testAddSkill

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@Test
public void testAddSkill(@ArquillianResource URL baseUrl) throws IOException {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target = client.target(baseUrl.toExternalForm() + "rest");
    SkillRestService skillRestService = target.proxy(SkillRestService.class);
    int tenantId = generateDatabase(baseUrl);
    
    skillRestService.addSkill(tenantId, new Skill(tenantId, "D"));
    
    List<Skill> skills = skillRestService.getSkillList(tenantId);
    
    assertEquals("List size don't match", SKILLS.length + 1, skills.size());
    
    for (String name : SKILLS) {
        assertContainsSkill(skills, tenantId, name);
    }
    assertContainsSkill(skills, tenantId, "D");
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:19,代碼來源:SkillRestServiceTest.java

示例2: put

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@Test
public void put(@ArquillianResource URL url) throws URISyntaxException {


  ClientBuilder.newClient().target(url.toURI())
    .path("customers")
    .request()
    .put(entity("[{\"firstName\": \"Joe\", \"lastName\": \"Doe\"}]", MediaType.APPLICATION_JSON_TYPE));

  Response response = ClientBuilder.newClient().target(url.toURI())
    .path("customers")
    .request(MediaType.APPLICATION_JSON)
    .get();


  List<Customer> customers = response.readEntity(new GenericType<List<Customer>>() {});

  Customer customer = new Customer();
  customer.setFirstName("Joe");
  customer.setLastName("Doe");

  assertThat(customers).isEqualTo(List.of(customer));
}
 
開發者ID:openknowledge,項目名稱:reactive-jax-rs,代碼行數:24,代碼來源:CustomerTest.java

示例3: testGetSkill

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@Test
public void testGetSkill(@ArquillianResource URL baseUrl) throws IOException {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target = client.target(baseUrl.toExternalForm() + "rest");
    SkillRestService skillRestService = target.proxy(SkillRestService.class);
    int tenantId = generateDatabase(baseUrl);
    
    List<Skill> skills = skillRestService.getSkillList(tenantId);
    
    Skill skill1 = getSkill(skills, "A").get();
    Skill skill2 = skillRestService.getSkill(tenantId, skill1.getId());
    
    assertNotNull("REST method did not return a result", skill2);
    assertEquals(skill1.getId(), skill2.getId());
    assertEquals(skill1.getName(), skill2.getName());
    assertEquals(skill1.getTenantId(), skill2.getTenantId());
    
    assertEquals("List size don't match", SKILLS.length, skills.size());
    
    for (String name : SKILLS) {
        assertContainsSkill(skills, tenantId, name);
    }
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:24,代碼來源:SkillRestServiceTest.java

示例4: lookup

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    final CloudsRegistry cloudsRegistry = registry.get();
    for (Annotation an : qualifiers) {
        if (an.annotationType() == InjectNode.class) {
            final InjectNode injectNode = (InjectNode) an;
            final String node = injectNode.value();
            String provider = new ObjectProperties(ObjectType.NODE, node).getProperty(ArquillianConfig.Node.PROVIDER);
            return cloudsRegistry.getNode(provider, node);
        }
    }
    // check if only one node is in the registry - and inject it
    Set<Node> nodeSet = cloudsRegistry.getAllNodes();
    if (nodeSet.size() == 1) {
        final Node singleNode = nodeSet.iterator().next();
        LOGGER.warn(
                "The @InjectNode annotation was not used to select Node to inject into the test. A Node registry holds only one entry ('{}') which will be used instead.",
                singleNode.getName());
        return singleNode;
    }
    throw new RuntimeException("Unable to find Node to inject. Use annotation @" + InjectNode.class.getName());
}
 
開發者ID:wildfly-extras,項目名稱:sunstone,代碼行數:23,代碼來源:NodeResourceProvider.java

示例5: lookup

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
    final CloudsRegistry cloudsRegistry = registry.get();
    for (Annotation an : qualifiers) {
        if (an.annotationType() == InjectCloudProvider.class) {
            return cloudsRegistry.getProvider(((InjectCloudProvider) an).value());
        }
    }
    // check if only one cloud provider is in the registry - and inject it
    final Set<String> cloudProviderNames = cloudsRegistry.getCloudProviderNames();
    if (cloudProviderNames.size() == 1) {
        final String singleProvider = cloudProviderNames.iterator().next();
        LOGGER.warn(
                "The @InjectCloudProvider annotation was not used to select CloudProvider to inject into the test. The CloudRegistry holds only one entry ('{}') which will be used instead.",
                singleProvider);
        return cloudsRegistry.getProvider(singleProvider);
    }
    throw new RuntimeException(
            "Unable to find CloudProvider to inject. Use annotation @" + InjectCloudProvider.class.getName());
}
 
開發者ID:wildfly-extras,項目名稱:sunstone,代碼行數:21,代碼來源:CloudProviderResourceProvider.java

示例6: testSessionListenerCalled

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
public void testSessionListenerCalled(@ArquillianResource URL baseURL) throws IOException {
  URL urlTest = url(baseURL, "FirstServlet", "testListenerCalled");
  String originalCookie = callWebapp(urlTest);
  HttpURLConnection connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, originalCookie);
  connection.connect();
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: B"));
  assertCookiesMatch(originalCookie, cookies);
  URL urlQueryListener = url(baseURL, "SessionListener", "testListenerCalled");
  HttpURLConnection listenerConnection = (HttpURLConnection) urlQueryListener.openConnection();
  assertThat(listenerConnection, matchLines("Create called: 2", "Destroy called: 1"));
  URL urlInvalidate = url(baseURL, "InvalidateServlet", "testListenerCalled");
  HttpURLConnection invalidateConnection = (HttpURLConnection) urlInvalidate.openConnection();
  setSessionCookie(invalidateConnection, originalCookie);
  assertThat(invalidateConnection, matchLines("Invalidated", "newSessionIdAfterInvalidate"));
  listenerConnection = (HttpURLConnection) urlQueryListener.openConnection();
  assertThat(listenerConnection, matchLines("Create called: 3", "Destroy called: 2"));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:23,代碼來源:AgentServlet2xITSessionWithCookieSomeFilter.java

示例7: testSessionPropagatedChangeServlets

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
public void testSessionPropagatedChangeServlets(@ArquillianResource URL baseURL) throws IOException {
  URL urlTest = url(baseURL, "FirstServlet", "testSessionPropagatedChangeServlets");
  String originalCookie = callWebapp(urlTest);
  URL urlOther = url(baseURL, "OtherServlet", "testSessionPropagatedChangeServlets");
  HttpURLConnection connection = (HttpURLConnection) urlOther.openConnection();
  setSessionCookie(connection, originalCookie);
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: B", "New value of attribute: C"));
  assertCookiesMatch(originalCookie, cookies);
  connection = (HttpURLConnection) urlOther.openConnection();
  setSessionCookie(connection, cookies);
  cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: C", "New value of attribute: C"));
  connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, cookies);
  connection.connect();
  cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: C", "New value of attribute: B"));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:25,代碼來源:AbstractITSessionWithCookie.java

示例8: testSessionRemoveAttributes

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
@OperateOnDeployment("session-operations")
public void testSessionRemoveAttributes(@ArquillianResource URL baseURL) throws IOException {
  URL url = url(baseURL, "TestServlet", "testSessionRemoveAttributes");
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: null", "New value of attribute: B"));
  url = url(baseURL, "RemoveAttributeServlet", "testSessionRemoveAttributes");
  System.out.println("COOKIES:" + cookies);
  connection = (HttpURLConnection) url.openConnection();
  setSessionCookie(connection, cookies);

  assertThat(connection, matchLines("Previous value of attribute: B", "New value of attribute: null"));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:17,代碼來源:ArqITSessionOperations.java

示例9: testSessionGetAttributes

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
@OperateOnDeployment("session-operations")
public void testSessionGetAttributes(@ArquillianResource URL baseURL) throws IOException {
  URL url = url(baseURL, "TestServlet", "testSessionGetAttributes");
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: null", "New value of attribute: B"));
  url = url(baseURL, "GetAllAttributes", "testSessionGetAttributes");
  connection = (HttpURLConnection) url.openConnection();
  setSessionCookie(connection, cookies);

  assertThat(connection, matchLines("Attributes in session: [A]"));
  url = url(baseURL, "AddAttributeServlet", "testSessionGetAttributes");
  connection = (HttpURLConnection) url.openConnection();
  setSessionCookie(connection, cookies);
  assertThat(connection, matchLines("Previous value of attribute B: null", "New value of attribute B: D"));
  url = url(baseURL, "GetAllAttributes", "testSessionGetAttributes");
  connection = (HttpURLConnection) url.openConnection();
  setSessionCookie(connection, cookies);
  assertThat(connection, matchLines("Attributes in session: [A, B]"));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:24,代碼來源:ArqITSessionOperations.java

示例10: testDefaultSessionDoesNotExpireIn2Seconds

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
@OperateOnDeployment("no-settings")
public void testDefaultSessionDoesNotExpireIn2Seconds(@ArquillianResource URL baseURL) throws IOException, InterruptedException {
  URL urlTest = url(baseURL, "TestServlet", "testDefaultSessionDoesNotExpireIn2Seconds");
  String originalCookie = callWebapp(urlTest);
  await(1000);
  HttpURLConnection connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, originalCookie);
  connection.connect();
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertFirstLineEquals(connection, "Previous value of attribute: B");
  assertThat(cookies, hasItem(originalCookie));
  await(2100);
  connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, originalCookie);
  connection.connect();
  cookies = connection.getHeaderFields().get("Set-Cookie");
  assertFirstLineEquals(connection, "Previous value of attribute: B");
  assertThat(cookies, hasItem(originalCookie));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:23,代碼來源:ArqITSessionExpire.java

示例11: testWhenSessionNeverExpires

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
@OperateOnDeployment("never-expires")
public void testWhenSessionNeverExpires(@ArquillianResource URL baseURL) throws IOException, InterruptedException {
  URL urlTest = url(baseURL, "TestServlet", "testWhenSessionNeverExpires");
  String originalCookie = callWebapp(urlTest);
  await(1000);
  HttpURLConnection connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, originalCookie);
  connection.connect();
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertFirstLineEquals(connection, "Previous value of attribute: B");
  assertThat(cookies, hasItem(originalCookie));
  await(2100);
  connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, originalCookie);
  connection.connect();
  cookies = connection.getHeaderFields().get("Set-Cookie");
  assertFirstLineEquals(connection, "Previous value of attribute: B");
  assertThat(cookies, hasItem(originalCookie));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:23,代碼來源:ArqITSessionExpire.java

示例12: testSessionPropagatedChangeServlets

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
public void testSessionPropagatedChangeServlets(@ArquillianResource URL baseURL) throws IOException {
  URL urlTest = url(baseURL, "TestServlet", "testSessionPropagatedChangeServlets");
  String originalCookie = callWebapp(urlTest);
  URL urlOther = url(baseURL, "OtherServlet", "testSessionPropagatedChangeServlets");
  HttpURLConnection connection = (HttpURLConnection) urlOther.openConnection();
  setSessionCookie(connection, originalCookie);
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: B", "New value of attribute: C"));
  assertThat(cookies, hasItem(originalCookie));
  connection = (HttpURLConnection) urlOther.openConnection();
  setSessionCookie(connection, cookies);
  cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: C", "New value of attribute: C"));
  connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, cookies);
  connection.connect();
  cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: C", "New value of attribute: B"));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:25,代碼來源:ArqITSessionWithCookie.java

示例13: testSessionSwitched

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
public void testSessionSwitched(@ArquillianResource URL baseURL) throws IOException {
  URL urlTest = url(baseURL, "TestServlet", "testSessionSwitched");
  String originalCookie = callWebapp(urlTest);
  HttpURLConnection connection = (HttpURLConnection) urlTest.openConnection();
  setSessionCookie(connection, originalCookie);
  connection.connect();
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");

  assertThat(connection, matchLines("Previous value of attribute: B"));
  assertThat(cookies, hasItem(originalCookie));

  URL urlOther = url(baseURL, "SwitchServlet", "testSessionSwitched");
  HttpURLConnection connectionOther = (HttpURLConnection) urlOther.openConnection();
  setSessionCookie(connectionOther, originalCookie);
  connectionOther.connect();
  List<String> switchedCookies = connectionOther.getHeaderFields().get("Set-Cookie");

  assertThat(connectionOther, matchLines("Previous value of attribute: B", "New value of attribute: S"));
  assertThat(switchedCookies, not(hasItem(originalCookie)));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:23,代碼來源:ArqITSessionWithCookie.java

示例14: testSessionIdIsUuid

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
@OperateOnDeployment("uuid")
public void testSessionIdIsUuid(@ArquillianResource URL baseURL) throws IOException {
  URL urlTest = url(baseURL, "TestServlet", "testSessionIdIsUuid");
  String originalCookie = callWebapp(urlTest);
  String justCookie = originalCookie.split(";", 2)[0];
  assertThat(justCookie, containsString("-"));
  assertThat(justCookie, startsWith("JSESSIONID="));
  try {
    UUID.fromString(justCookie.substring("JSESSIONID=".length()));
  } catch (Exception e) {
    fail("Invalid format of UUID " + justCookie);
  }
  HttpURLConnection connection = (HttpURLConnection)urlTest.openConnection();
  setSessionCookie(connection, originalCookie);
  assertFirstLineEquals(connection, "Previous value of attribute: B");
  List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
  assertThat(cookies, hasItem(originalCookie));
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:21,代碼來源:ArqITSessionUUIDCookies.java

示例15: testSessionNotPropagatedToOtherWebapp

import org.jboss.arquillian.test.api.ArquillianResource; //導入依賴的package包/類
@RunAsClient
@Test
@OperateOnDeployment(FIRST_WEBAPP)
public void testSessionNotPropagatedToOtherWebapp(@ArquillianResource @OperateOnDeployment(FIRST_WEBAPP) URL firstURL,
    @ArquillianResource @OperateOnDeployment(SECOND_WEBAPP) URL secondURL) throws IOException {
  URL urlTestFirst = url(firstURL, "TestServlet", "testSessionNotPropagatedToOtherWebapp");
  URL urlTestSecond = url(secondURL, "SecondServlet", "testSessionNotPropagatedToOtherWebapp");
  String originalCookie = callWebapp(urlTestFirst);
  System.out.println("First app cookies: " + originalCookie);
  String secondCookie = callSecondWebApp(urlTestSecond, originalCookie);
  // Call again first webapp with cookie from first webapp, it works
  HttpURLConnection connection = (HttpURLConnection) urlTestFirst.openConnection();
  setSessionCookie(connection, originalCookie);
  connection.connect();

  assertFirstLineEquals(connection, "Previous value of attribute: B");

  // Call again first webapp with cookie from second webapp, it creates new
  // session
  connection = (HttpURLConnection) urlTestFirst.openConnection();
  setSessionCookie(connection, secondCookie);
  connection.connect();
  String newCookie = connection.getHeaderFields().get("Set-Cookie").get(0);
  Assert.assertFalse(originalCookie.equals(newCookie));
  assertFirstLineEquals(connection, "Previous value of attribute: null");
}
 
開發者ID:AmadeusITGroup,項目名稱:HttpSessionReplacer,代碼行數:27,代碼來源:ArqITSessionWithCookieTwoApps.java


注:本文中的org.jboss.arquillian.test.api.ArquillianResource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。