| | |
| | | /* |
| | | * Copyright 2011 gitblit.com. |
| | | * Copyright 2013 gitblit.com. |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | |
| | | */ |
| | | package com.gitblit.tests; |
| | | |
| | | import com.gitblit.utils.JGitUtils; |
| | | import com.gitblit.utils.JnaUtils; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import static org.junit.Assert.assertEquals; |
| | | import static org.junit.Assert.assertTrue; |
| | | |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.eclipse.jgit.lib.Repository; |
| | |
| | | import org.eclipse.jgit.util.FS; |
| | | import org.junit.Test; |
| | | |
| | | import com.gitblit.utils.JGitUtils; |
| | | import com.gitblit.utils.JnaUtils; |
| | | |
| | | /** |
| | | * |
| | | * @author Florian Zschocke |
| | | */ |
| | | public class JnaUtilsTest { |
| | | public class JnaUtilsTest extends GitblitUnitTest { |
| | | |
| | | @Test |
| | | public void testGetgid() { |
| | | if (JnaUtils.isWindows()) { |
| | | try { |
| | | JnaUtils.getFilemode(GitBlitSuite.REPOSITORIES); |
| | | } catch(UnsupportedOperationException e) {} |
| | | } |
| | | else { |
| | | int gid = JnaUtils.getgid(); |
| | | assertTrue(gid >= 0); |
| | | int egid = JnaUtils.getegid(); |
| | | assertTrue(egid >= 0); |
| | | assertTrue("Really? You're running unit tests as root?!", gid > 0); |
| | | System.out.println("gid: " + gid + " egid: " + egid); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void testGetFilemode() throws IOException { |
| | |
| | | FileUtils.deleteDirectory(repository.getDirectory()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void testGetFilestat() { |
| | | if (JnaUtils.isWindows()) { |
| | | try { |
| | | JnaUtils.getFilemode(GitBlitSuite.REPOSITORIES); |
| | | } catch(UnsupportedOperationException e) {} |
| | | } |
| | | else { |
| | | JnaUtils.Filestat stat = JnaUtils.getFilestat(GitBlitSuite.REPOSITORIES); |
| | | assertNotNull(stat); |
| | | assertTrue(stat.mode > 0); |
| | | assertTrue(stat.uid > 0); |
| | | assertTrue(stat.gid > 0); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |