Package org.sonatype.nexus.rest.model

Examples of org.sonatype.nexus.rest.model.RepositoryResource


  @Test
  public void createRepositoryTest()
      throws IOException
  {

    final RepositoryResource resource = new RepositoryResource();

    resource.setId("createTestRepo");
    resource.setRepoType("hosted");
    resource.setName("Create Test Repo");
    resource.setProvider("p2");
    resource.setFormat("p2");
    resource.setRepoPolicy(RepositoryPolicy.MIXED.name());

    messageUtil.createRepository(resource);
  }
View Full Code Here


  @Test
  public void readTest()
      throws IOException
  {

    final RepositoryResource resource = new RepositoryResource();

    resource.setId("readTestRepo");
    resource.setRepoType("hosted");
    resource.setName("Read Test Repo");
    resource.setProvider("p2");
    resource.setFormat("p2");
    resource.setRepoPolicy(RepositoryPolicy.MIXED.name());

    messageUtil.createRepository(resource);

    final RepositoryResource responseRepo = (RepositoryResource) messageUtil.getRepository(resource.getId());

    messageUtil.validateResourceResponse(resource, responseRepo);

  }
View Full Code Here

  @Test
  public void createJunkOverrideUrlTest()
      throws IOException
  {

    RepositoryResource resource = new RepositoryResource();

    resource.setId("createJunkOverrideUrlTest");
    resource.setRepoType("hosted"); // [hosted, proxy, virtual]
    resource.setName("Create Test Repo");
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    // resource.setAllowWrite( true );
    // resource.setBrowseable( true );
    // resource.setIndexable( true );
    // resource.setNotFoundCacheTTL( 1440 );
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // resource.setRealmnId(?)
    resource.setOverrideLocalStorageUrl("foo.bar"); // file://repos/internal
    // resource.setDefaultLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDownloadRemoteIndexes( true );
    resource.setChecksumPolicy("IGNORE"); // [ignore, warn, strictIfExists, strict]

    Response response = this.messageUtil.sendMessage(Method.POST, resource);
    String responseText = response.getEntity().getText();

    Assert.assertFalse("Repo should not have been created: " + response.getStatus() + "\n" + responseText,
View Full Code Here

  @Test
  public void createJunkDefaultStorageUrlTest()
      throws IOException
  {

    RepositoryResource resource = new RepositoryResource();

    resource.setId("createJunkDefaultStorageUrlTest");
    resource.setRepoType("proxy"); // [hosted, proxy, virtual]
    resource.setName("Create Test Repo");
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    // resource.setAllowWrite( true );
    // resource.setBrowseable( true );
    // resource.setIndexable( true );
    // resource.setNotFoundCacheTTL( 1440 );
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // resource.setRealmnId(?)
    // resource.setOverrideLocalStorageUrl( "" ); //file://repos/internal
    resource.setDefaultLocalStorageUrl("foo.bar"); // file://repos/internal
    // resource.setDownloadRemoteIndexes( true );
    resource.setChecksumPolicy("IGNORE"); // [ignore, warn, strictIfExists, strict]

    Response response = this.messageUtil.sendMessage(Method.POST, resource);
    String responseText = response.getEntity().getText();

    Assert.assertTrue("Expected DefaultLocalStorageUrl to be ignored on create"
View Full Code Here

  @Test
  public void updateValidatioinTest()
      throws IOException
  {
    RepositoryResource resource = new RepositoryResource();

    resource.setId("updateValidatioinTest");
    resource.setRepoType("proxy"); // [hosted, proxy, virtual]
    resource.setName("Update Test Repo");
    // resource.setRepoType( ? )
    resource.setProvider("maven2");
    // format is neglected by server from now on, provider is the new guy in the town
    resource.setFormat("maven2"); // Repository Format, maven1, maven2, maven-site, eclipse-update-site
    // resource.setAllowWrite( true );
    // resource.setBrowseable( true );
    // resource.setIndexable( true );
    // resource.setNotFoundCacheTTL( 1440 );
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name()); // [snapshot, release] Note: needs param name change
    // resource.setRealmnId(?)
    // resource.setOverrideLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDefaultLocalStorageUrl( "" ); //file://repos/internal
    // resource.setDownloadRemoteIndexes( true );
    resource.setChecksumPolicy("IGNORE"); // [ignore, warn, strictIfExists, strict]
    RepositoryResourceRemoteStorage remote = new RepositoryResourceRemoteStorage();
    remote.setRemoteStorageUrl("http://localhost:123/remote_resource_repo/");
    resource.setRemoteStorage(remote);

    // this also validates
    resource = (RepositoryResource) this.messageUtil.createRepository(resource);

    // invalid policy
    resource.setRepoPolicy("junk");
    this.sendAndExpectError(Method.PUT, resource);
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());

    // invalid policy
    resource.setRepoPolicy("junk");
    Response response = this.messageUtil.sendMessage(Method.PUT, resource);
    this.sendAndExpectError(Method.PUT, resource);
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());

    // no policy
    resource.setRepoPolicy(null);
    this.sendAndExpectError(Method.PUT, resource);
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());

    // invalid override local storage
    resource.setOverrideLocalStorageUrl("foo.bar");
    this.sendAndExpectError(Method.PUT, resource);
    resource.setOverrideLocalStorageUrl(null);

    // invalid checksum
    resource.setChecksumPolicy("JUNK");
    this.sendAndExpectError(Method.PUT, resource);
    resource.setChecksumPolicy("IGNORE");

    // no checksum
    resource.setChecksumPolicy(null);
    this.sendAndExpectError(Method.PUT, resource);
    resource.setChecksumPolicy("IGNORE");
  }
View Full Code Here

  }

  protected void createProxyRepository()
      throws Exception
  {
    RepositoryResource resource = new RepositoryResource();

    resource.setProvider("maven2");
    resource.setFormat("maven2");
    resource.setRepoPolicy("release");
    resource.setChecksumPolicy("ignore");
    resource.setBrowseable(false);
    resource.setIndexable(false);

    resource.setId(PROXY_REPO_ID);
    resource.setName(PROXY_REPO_ID);
    resource.setRepoType("proxy");
    resource.setWritePolicy(RepositoryWritePolicy.READ_ONLY.name());
    resource.setDownloadRemoteIndexes(true);
    RepositoryResourceRemoteStorage remoteStorage = new RepositoryResourceRemoteStorage();
    remoteStorage.setRemoteStorageUrl(getBaseNexusUrl() + "content/repositories/nexus-test-harness-repo/");
    resource.setRemoteStorage(remoteStorage);
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());
    resource.setChecksumPolicy(ChecksumPolicy.IGNORE.name());
    new RepositoryMessageUtil(this.getJsonXStream(), MediaType.APPLICATION_JSON).createRepository(resource);
  }
View Full Code Here

  @Test
  public void downloadChecksumTest()
      throws Exception
  {
    RepositoryResource basic = (RepositoryResource) repoUtil.getRepository("basic");
    // ensure URL
    assertThat(basic.getRemoteStorage().getRemoteStorageUrl(),
        equalTo("http://localhost:" + webProxyPort + "/repository/"));
    // ensure is not downloading index
    assertThat(basic.isDownloadRemoteIndexes(), is(false));

    // reindex once
    RepositoryMessageUtil.updateIndexes("basic");
    TaskScheduleUtil.waitForAllTasksToStop(UpdateIndexTask.class);

    // first try, download remote index set to false, no index should be pulled
    assertThat(accessedPaths, empty());

    // server changed here, a 404 is no longer returned if index_context is empty, 404 will only be returned
    // if index_context does not exist (or repo does not exist)
    String content = RequestFacade.doGetForText(URI);

    XStream xstream = XStreamFactory.getXmlXStream();

    xstream.processAnnotations(IndexBrowserTreeNodeDTO.class);
    xstream.processAnnotations(IndexBrowserTreeViewResponseDTO.class);

    XStreamRepresentation re = new XStreamRepresentation(xstream, content, MediaType.APPLICATION_XML);
    IndexBrowserTreeViewResponseDTO resourceResponse =
        (IndexBrowserTreeViewResponseDTO) re.getPayload(new IndexBrowserTreeViewResponseDTO());

    assertThat("without index downloaded root node does not have children", resourceResponse.getData().getChildren(),
        is(nullValue()));

    // I changed my mind, I do wanna remote index
    basic.setDownloadRemoteIndexes(true);
    repoUtil.updateRepo(basic);

    // reindex again
    RepositoryMessageUtil.updateIndexes("basic");
    TaskScheduleUtil.waitForAllTasksToStop(UpdateIndexTask.class);
View Full Code Here

    RequestFacade.doGet(RequestFacade.SERVICE_LOCAL + "repositories/" + repoId + "/index_content/");

    RepositoryMessageUtil repoUtil =
        new RepositoryMessageUtil(this.getXMLXStream(), MediaType.APPLICATION_XML);

    RepositoryResource resource = (RepositoryResource) repoUtil.getRepository(repoId);
    resource.setIndexable(false);
    repoUtil.updateRepo(resource);

    // get the index tree
    RequestFacade.doGet(RequestFacade.SERVICE_LOCAL + "repositories/" + repoId + "/index_content/",
        respondsWithStatusCode(404));
View Full Code Here

  @Test
  public void repositoryIdLegal()
      throws Exception
  {
    RepositoryResource resource = new RepositoryResource();
    resource.setRepoType("hosted"); // [hosted, proxy, virtual]
    resource.setName("Create Test Repo");
    resource.setProvider("maven2");
    resource.setFormat("maven2");
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());

    resource.setId("repoaA1-_.");
    Response resp = repositoryMsgUtil.sendMessage(Method.POST, resource);
    Assert.assertTrue(resp.getStatus().isSuccess());
  }
View Full Code Here

  @Test
  public void repositoryIdIllegal()
      throws Exception
  {
    RepositoryResource resource = new RepositoryResource();
    resource.setRepoType("hosted"); // [hosted, proxy, virtual]
    resource.setName("Create Test Repo");
    resource.setProvider("maven2");
    resource.setFormat("maven2");
    resource.setRepoPolicy(RepositoryPolicy.RELEASE.name());

    resource.setId("repo/");
    Response resp = repositoryMsgUtil.sendMessage(Method.POST, resource);
    Assert.assertFalse(resp.getStatus().isSuccess());

    resource.setId("repo,");
    resp = repositoryMsgUtil.sendMessage(Method.POST, resource);
    Assert.assertFalse(resp.getStatus().isSuccess());

    resource.setId("repo*");
    resp = repositoryMsgUtil.sendMessage(Method.POST, resource);
    Assert.assertFalse(resp.getStatus().isSuccess());

    resource.setId("repo>");
    resp = repositoryMsgUtil.sendMessage(Method.POST, resource);
    Assert.assertFalse(resp.getStatus().isSuccess());
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.RepositoryResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.