List of usage examples for org.apache.commons.lang.reflect FieldUtils readField
public static Object readField(Object target, String fieldName, boolean forceAccess) throws IllegalAccessException
From source file:org.commonjava.maven.ext.cli.CliTest.java
@Test public void checkTargetMatchesWithRun() throws Exception { Cli c = new Cli(); File pom1 = temp.newFile();//w w w . ja v a 2s . c om executeMethod(c, "run", new Object[] { new String[] { "-f", pom1.toString() } }); assertTrue("Session file should match", pom1.equals(((ManipulationSession) FieldUtils.readField(c, "session", true)).getPom())); }
From source file:org.commonjava.maven.ext.cli.CliTest.java
@Test public void checkTargetDefaultMatches() throws Exception { Cli c = new Cli(); executeMethod(c, "run", new Object[] { new String[] {} }); ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true); File defaultTarget = (File) FieldUtils.readField(c, "target", true); assertTrue("Session file should match", defaultTarget.equals(session.getPom())); }
From source file:org.commonjava.maven.ext.cli.CliTest.java
@Test public void checkLocalRepositoryWithDefaults() throws Exception { Cli c = new Cli(); File settings = writeSettings(temp.newFile()); executeMethod(c, "run", new Object[] { new String[] { "-s", settings.toString() } }); ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true); MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true); assertTrue(ms.getRequest().getLocalRepository().getBasedir() .equals(ms.getRequest().getLocalRepositoryPath().toString())); assertTrue(//w w w. ja v a2 s. co m "File " + new File(ms.getRequest().getLocalRepository().getBasedir()).getParentFile().toString() + " was not equal to " + System.getProperty("user.home") + File.separatorChar + ".m2", new File(ms.getRequest().getLocalRepository().getBasedir()).getParentFile().toString() .equals(System.getProperty("user.home") + File.separatorChar + ".m2")); }
From source file:org.commonjava.maven.ext.cli.CliTest.java
@Test public void checkLocalRepositoryWithDefaultsAndModifiedUserSettings() throws Exception { boolean restore = false; Path source = Paths.get( System.getProperty("user.home") + File.separatorChar + ".m2" + File.separatorChar + "settings.xml"); Path backup = Paths.get(source.toString() + '.' + UUID.randomUUID().toString()); Path tmpSettings = Paths.get(getClass().getResource("/settings-test.xml").getFile()); try {/* w w w. j av a 2 s.c o m*/ if (source.toFile().exists()) { System.out.println("Backing up settings.xml to " + backup); restore = true; Files.move(source, backup, StandardCopyOption.ATOMIC_MOVE); } Files.copy(tmpSettings, source); Cli c = new Cli(); executeMethod(c, "run", new Object[] { new String[] {} }); ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true); MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true); assertTrue(ms.getRequest().getLocalRepository().getBasedir() .equals(ms.getRequest().getLocalRepositoryPath().toString())); assertTrue(ms.getLocalRepository().getBasedir() .equals(System.getProperty("user.home") + File.separatorChar + ".m2-mead-test")); } finally { if (restore) { Files.move(backup, source, StandardCopyOption.ATOMIC_MOVE); } else { Files.delete(source); } } }
From source file:org.commonjava.maven.ext.cli.CliTest.java
@Test public void checkLocalRepositoryWithSettings() throws Exception { Cli c = new Cli(); executeMethod(c, "run", new Object[] { new String[] { "-settings=" + getClass().getResource("/settings-test.xml").getFile() } }); ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true); MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true); assertTrue(ms.getRequest().getLocalRepository().getBasedir() .equals(ms.getRequest().getLocalRepositoryPath().toString())); }
From source file:org.commonjava.maven.ext.cli.CliTest.java
@Test public void checkLocalRepositoryWithExplicitMavenRepo() throws Exception { File folder = temp.newFolder(); Cli c = new Cli(); executeMethod(c, "run", new Object[] { new String[] { "-Dmaven.repo.local=" + folder.toString() } }); ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true); MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true); assertTrue(ms.getRequest().getLocalRepository().getBasedir() .equals(ms.getRequest().getLocalRepositoryPath().toString())); }
From source file:org.commonjava.maven.ext.cli.CliTest.java
@Test public void checkLocalRepositoryWithExplicitMavenRepoAndSettings() throws Exception { File folder = temp.newFolder(); Cli c = new Cli(); executeMethod(c, "run", new Object[] { new String[] { "-settings=" + getClass().getResource("/settings-test.xml").getFile(), "-Dmaven.repo.local=" + folder.toString() } }); ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true); MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true); assertTrue(ms.getLocalRepository().getBasedir().equals(folder.toString())); assertTrue(ms.getRequest().getLocalRepository().getBasedir() .equals(ms.getRequest().getLocalRepositoryPath().toString())); }
From source file:org.commonjava.maven.ext.manip.CliTest.java
@Test public void checkTargetMatches() throws Exception { Cli c = new Cli(); File pom1 = new File("/tmp/foobar"); File settings1 = new File("/tmp/foobarsettings"); executeMethod(c, "createSession", new Object[] { pom1, settings1 }); assertTrue("Session file should match", pom1.equals(((ManipulationSession) FieldUtils.readField(c, "session", true)).getPom())); }
From source file:org.commonjava.maven.ext.manip.CliTest.java
@Test public void checkTargetMatchesWithRun() throws Exception { Cli c = new Cli(); File pom1 = new File("/tmp/foobar"); executeMethod(c, "run", new Object[] { new String[] { "-f", pom1.toString() } }); assertTrue("Session file should match", pom1.equals(((ManipulationSession) FieldUtils.readField(c, "session", true)).getPom())); }
From source file:org.dspace.app.xmlui.aspect.general.PageNotFoundTransformer.java
private boolean isRedirect() { final HttpServletResponse response = (HttpServletResponse) objectModel .get(HttpEnvironment.HTTP_RESPONSE_OBJECT); try {//from ww w. j a va2 s .c o m return ((int) FieldUtils.readField(response, "statusCode", true)) == HttpServletResponse.SC_TEMPORARY_REDIRECT; } catch (Exception e) { return false; } }