Debian Codegraph @

src/test/java/org/jboss/modules/MavenResourceTest.java

raw
1 /*
2 * JBoss, Home of Professional Open Source.
3 * Copyright 2014 Red Hat, Inc., and individual contributors
4 * as indicated by the @author tags.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.jboss.modules;
20
21 import java.io.File;
22 import java.net.URL;
23
24 import org.jboss.modules.maven.ArtifactCoordinates;
25 import org.jboss.modules.maven.MavenArtifactUtil;
26 import org.jboss.modules.maven.MavenSettingsTest;
27 import org.jboss.modules.util.Util;
28 import org.junit.Assert;
29 import org.junit.Before;
30 import org.junit.Ignore;
31 import org.junit.Rule;
32 import org.junit.Test;
33 import org.junit.rules.TemporaryFolder;
34
35 /**
36 * @author <a href="mailto:[email protected]">Bill Burke</a>
37 * @version $Revision: 1 $
38 */
39 public class MavenResourceTest {
40
41 protected static final String MODULE_ID = "test.maven";
42
43 @Rule
44 public TemporaryFolder tmpdir = new TemporaryFolder();
45
46 private ModuleLoader moduleLoader;
47
48 @Before
49 public void setupRepo() throws Exception {
50 final File repoRoot = Util.getResourceFile(getClass(), "test/repo");
51 moduleLoader = new LocalModuleLoader(new File[]{repoRoot});
52 }
53
54 @Test
55 public void testWithPassedRepository() throws Exception {
56 System.setProperty("maven.repo.local", tmpdir.newFolder("repository").getAbsolutePath());
57 System.setProperty("remote.maven.repo", "https://repository.jboss.org/nexus/content/groups/public/,https://maven-central.storage.googleapis.com/");
58 try {
59 Module module = moduleLoader.loadModule(MODULE_ID);
60 URL url = module.getResource("org/jboss/resteasy/plugins/providers/jackson/ResteasyJacksonProvider.class");
61 System.out.println(url);
62 Assert.assertNotNull(url);
63 } finally {
64 System.clearProperty("maven.repo.local");
65 System.clearProperty("remote.repository");
66 }
67 }
68
69 /**
70 * we test if it uses repostiory user has configured in user.home/.m2/settings.xml or M2_HOME/conf/settings.xml
71 *
72 * @throws Exception
73 */
74 @Test
75 @Ignore("Test is mostly meant for manual testing, as snapshot are not parmanent")
76 public void testCustomRepository() throws Exception {
77 File f = MavenArtifactUtil.resolveJarArtifact(ArtifactCoordinates.fromString("org.wildfly.core:wildfly-version:2.0.5.Final-20151222.144931-1"));
78 Assert.assertNotNull("Should resolve", f);
79 System.out.println("f = " + f);
80 }
81 }