converted logging to slf4j
This commit is contained in:
@ -259,5 +259,10 @@
|
|||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@ -1,14 +1,14 @@
|
|||||||
package de.muehlencord.shared.sharepoint.api;
|
package de.muehlencord.shared.sharepoint.api;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.xml.transform.OutputKeys;
|
import javax.xml.transform.OutputKeys;
|
||||||
import javax.xml.transform.Transformer;
|
import javax.xml.transform.Transformer;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
import javax.xml.transform.TransformerFactory;
|
import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
@ -18,6 +18,8 @@ import org.w3c.dom.Node;
|
|||||||
*/
|
*/
|
||||||
public abstract class SPObject {
|
public abstract class SPObject {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(SPObject.class.getName());
|
||||||
|
|
||||||
private SPContext context;
|
private SPContext context;
|
||||||
|
|
||||||
public SPObject(SPContext context) {
|
public SPObject(SPContext context) {
|
||||||
@ -53,7 +55,7 @@ public abstract class SPObject {
|
|||||||
//print the XML
|
//print the XML
|
||||||
returnString = returnString + xmlString;
|
returnString = returnString + xmlString;
|
||||||
} catch (TransformerException ex) {
|
} catch (TransformerException ex) {
|
||||||
Logger.getLogger(SPObject.class.getName()).log(Level.SEVERE, null, ex);
|
LOGGER.error (ex.toString(), ex);
|
||||||
}
|
}
|
||||||
return returnString;
|
return returnString;
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ public abstract class SPObject {
|
|||||||
//print the XML
|
//print the XML
|
||||||
returnString = returnString + xmlString;
|
returnString = returnString + xmlString;
|
||||||
} catch (TransformerException ex) {
|
} catch (TransformerException ex) {
|
||||||
Logger.getLogger(SPObject.class.getName()).log(Level.SEVERE, null, ex);
|
LOGGER.error (ex.toString(), ex);
|
||||||
}
|
}
|
||||||
return returnString;
|
return returnString;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,73 @@
|
|||||||
|
package de.muehlencord.shared.sharepoint.api;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author joern.muehlencord
|
||||||
|
*/
|
||||||
|
public class SharepointConfig {
|
||||||
|
|
||||||
|
private Properties properties;
|
||||||
|
|
||||||
|
public void loadFromFile() throws IOException {
|
||||||
|
File configFile = new File(getConfigFile());
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
properties = createDefaultConfig();
|
||||||
|
storeToFile("sample");
|
||||||
|
|
||||||
|
System.out.println(createDefaultConfig());
|
||||||
|
throw new FileNotFoundException("Config file " + configFile.toString() + " not found. Please create it");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileInputStream fin = new FileInputStream(configFile);
|
||||||
|
properties = new Properties();
|
||||||
|
properties.loadFromXML(fin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeToFile() throws IOException {
|
||||||
|
storeToFile(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProperty(String key) {
|
||||||
|
if (properties.containsKey(key)) {
|
||||||
|
return properties.getProperty(key);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeToFile(String postfix) throws IOException {
|
||||||
|
String configFileName = getConfigFile();
|
||||||
|
if (postfix != null) {
|
||||||
|
configFileName += "." + postfix;
|
||||||
|
}
|
||||||
|
File configFile = new File(configFileName);
|
||||||
|
FileOutputStream fos = new FileOutputStream(configFile);
|
||||||
|
properties.storeToXML(fos, "Example config", "UTF-8");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Properties createDefaultConfig() {
|
||||||
|
Properties p = new Properties();
|
||||||
|
p.put("domainname", "domainname");
|
||||||
|
p.put("username", "username");
|
||||||
|
p.put("password", "password");
|
||||||
|
p.put("sharepointurl", "http://server/path/to/root");
|
||||||
|
p.put("workdir", "workdir");
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getConfigFile() {
|
||||||
|
String configPath = System.getProperty("user.home");
|
||||||
|
configPath = (configPath.endsWith(File.separator) ? configPath : configPath + File.separator);
|
||||||
|
configPath += ".wincornixdorf/sharepoint/sharepoint.properties";
|
||||||
|
return configPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -61,7 +61,6 @@ public class SPUserGroup extends SPObject {
|
|||||||
getUserGroupPort().removeUserFromGroup(groupName, "i:0#.w|" + user.getUserLoginName());
|
getUserGroupPort().removeUserFromGroup(groupName, "i:0#.w|" + user.getUserLoginName());
|
||||||
}
|
}
|
||||||
LOGGER.info("User " + user.getUserName() + " removed from group " + groupName);
|
LOGGER.info("User " + user.getUserName() + " removed from group " + groupName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUserMemberOfGroup(String userLoginName, String groupName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException {
|
public boolean isUserMemberOfGroup(String userLoginName, String groupName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException {
|
||||||
@ -193,11 +192,5 @@ public class SPUserGroup extends SPObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* *** unsorted *** */
|
/* *** unsorted *** */
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* History:
|
|
||||||
*
|
|
||||||
* $$Log$$
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|||||||
@ -8,28 +8,40 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import org.junit.Before;
|
import org.junit.BeforeClass;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author jomu
|
* @author joern@muehlencord.de
|
||||||
*/
|
*/
|
||||||
public abstract class BaseTest {
|
public abstract class BaseTest {
|
||||||
|
|
||||||
protected SPContext context = null;
|
private final static Logger LOGGER = LoggerFactory.getLogger(BaseTest.class.getName());
|
||||||
|
private static SPContext context = null;
|
||||||
|
|
||||||
@Before
|
@BeforeClass
|
||||||
public void init() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException, JAXBException {
|
public static void init() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException, JAXBException, IOException {
|
||||||
// FIXME - needs to be implemented using mock; replace with real data but make sure password is not commited
|
SharepointConfig config = new SharepointConfig();
|
||||||
NtlmAuthenticator credentials = null;
|
config.loadFromFile();
|
||||||
context = null;
|
|
||||||
// DO NOT COMMMT THE FOLLOWING LINES
|
String domainname = config.getProperty("domainname");
|
||||||
credentials = new NtlmAuthenticator("wincor-nixdorf.com", "joern.muehlencord", "\"34fR4vbHuL");
|
String username = config.getProperty("username");
|
||||||
context = new SPContext(new java.net.URL("https://troom.wincor-nixdorf.com/rooms/sw_ps_hq_utrecht/hqall/bd/spwin7/"), credentials, SPVersion.SP2010,
|
String password = config.getProperty("password");
|
||||||
true);
|
String sharepointurl = config.getProperty("sharepointurl");
|
||||||
|
// String workDir = config.getProperty("workdir");
|
||||||
|
|
||||||
|
NtlmAuthenticator credentials = new NtlmAuthenticator(domainname, username, password);
|
||||||
|
context = new SPContext(new java.net.URL(sharepointurl), credentials, SPVersion.SP2010, true);
|
||||||
|
LOGGER.info("Sharepoint context initialized");
|
||||||
|
|
||||||
|
// userGroup = new SPUserGroup(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SPContext getContext() {
|
||||||
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,10 +68,8 @@ public abstract class BaseTest {
|
|||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
}
|
}
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
Logger.getLogger(BaseTest.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
throw ex;
|
throw ex;
|
||||||
} catch (IOException ioex) {
|
} catch (IOException ioex) {
|
||||||
Logger.getLogger(BaseTest.class.getName()).log(Level.SEVERE, null, ioex);
|
|
||||||
throw ioex;
|
throw ioex;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@ -67,7 +77,7 @@ public abstract class BaseTest {
|
|||||||
br.close();
|
br.close();
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(BaseTest.class.getName()).log(Level.SEVERE, null, ex);
|
LOGGER.error (ex.toString(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -75,14 +85,14 @@ public abstract class BaseTest {
|
|||||||
irs.close();
|
irs.close();
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(BaseTest.class.getName()).log(Level.SEVERE, null, ex);
|
LOGGER.error (ex.toString(), ex);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(BaseTest.class.getName()).log(Level.SEVERE, null, ex);
|
LOGGER.error (ex.toString(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public class NtlmAuthenticatorTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testAuthentication() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException {
|
public void testAuthentication() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException {
|
||||||
SPSite instance = new SPSite(context);
|
SPSite instance = new SPSite(getContext());
|
||||||
// instance.getRootWeb();
|
// instance.getRootWeb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
package de.muehlencord.shared.sharepoint.api;
|
||||||
|
|
||||||
|
import de.muehlencord.shared.sharepoint.api.SharepointConfig;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author joern.muehlencord
|
||||||
|
*/
|
||||||
|
public class SharepointConfigTest {
|
||||||
|
|
||||||
|
public SharepointConfigTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoadFromFile() throws Exception {
|
||||||
|
SharepointConfig c = new SharepointConfig();
|
||||||
|
c.loadFromFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -25,7 +25,7 @@ public class SPListTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
String xmlString = readFileContentFromTest("lists/testlist.xml", "UTF-8");
|
String xmlString = readFileContentFromTest("lists/testlist.xml", "UTF-8");
|
||||||
SPList list = new SPList(context, "{924883B9-41B7-430C-8206-151786A67319}");
|
SPList list = new SPList(getContext(), "{924883B9-41B7-430C-8206-151786A67319}");
|
||||||
assertNotNull(xmlString);
|
assertNotNull(xmlString);
|
||||||
list.setValue(xmlString);
|
list.setValue(xmlString);
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ public class SPListTest extends BaseTest {
|
|||||||
public void addListItemByTitle() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException,
|
public void addListItemByTitle() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
SPList list = instance.getSpListByTitle("Test");
|
SPList list = instance.getSpListByTitle("Test");
|
||||||
assertNotNull(list);
|
assertNotNull(list);
|
||||||
String listName = list.getListName();
|
String listName = list.getListName();
|
||||||
@ -61,7 +61,7 @@ public class SPListTest extends BaseTest {
|
|||||||
public void addListItemBigList() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException,
|
public void addListItemBigList() throws NoSuchAlgorithmException, KeyManagementException, JAXBException, SAXException, ParserConfigurationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
SPList list = instance.getSpListByTitle("Questionnaire");
|
SPList list = instance.getSpListByTitle("Questionnaire");
|
||||||
assertNotNull(list);
|
assertNotNull(list);
|
||||||
String listName = list.getListName();
|
String listName = list.getListName();
|
||||||
@ -94,7 +94,7 @@ public class SPListTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testGetListItems() throws Exception {
|
public void testGetListItems() throws Exception {
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
|
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
|
||||||
assertNotNull(list);
|
assertNotNull(list);
|
||||||
java.util.List<String> columns = new ArrayList<>();
|
java.util.List<String> columns = new ArrayList<>();
|
||||||
@ -112,7 +112,7 @@ public class SPListTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testGetListItemsQuery() throws Exception {
|
public void testGetListItemsQuery() throws Exception {
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
|
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
|
||||||
assertNotNull(list);
|
assertNotNull(list);
|
||||||
java.util.List<String> columns = new ArrayList<>();
|
java.util.List<String> columns = new ArrayList<>();
|
||||||
@ -136,7 +136,7 @@ public class SPListTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testGetLookupValueMap() throws Exception {
|
public void testGetLookupValueMap() throws Exception {
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
|
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
|
||||||
Map<String, String> lookupValues = list.getLookupValueMap("Title", 0);
|
Map<String, String> lookupValues = list.getLookupValueMap("Title", 0);
|
||||||
System.out.println(lookupValues);
|
System.out.println(lookupValues);
|
||||||
@ -146,7 +146,7 @@ public class SPListTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testGetColumnNameByDisplayName() throws Exception {
|
public void testGetColumnNameByDisplayName() throws Exception {
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
SPList list = instance.getSpListByTitle("Questionnaire");
|
SPList list = instance.getSpListByTitle("Questionnaire");
|
||||||
assertEquals("Displayname of Current OS", "Current_x0020_OS", list.getColumnNameByDisplayName("Current OS"));
|
assertEquals("Displayname of Current OS", "Current_x0020_OS", list.getColumnNameByDisplayName("Current OS"));
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ public class SPListTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testGetItemCount() throws Exception {
|
public void testGetItemCount() throws Exception {
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
SPList list = instance.getSpListByTitle("Questionnaire");
|
SPList list = instance.getSpListByTitle("Questionnaire");
|
||||||
assertTrue(list.getItemCount() > 0);
|
assertTrue(list.getItemCount() > 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public class SPListsTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFromXML() throws IOException, JAXBException, SAXException {
|
public void testFromXML() throws IOException, JAXBException, SAXException {
|
||||||
String xmlString = readFileContentFromTest("lists/testlists.xml", "UTF-8");
|
String xmlString = readFileContentFromTest("lists/testlists.xml", "UTF-8");
|
||||||
SPLists lists = new SPLists(context);
|
SPLists lists = new SPLists(getContext());
|
||||||
lists.setValue (xmlString);
|
lists.setValue (xmlString);
|
||||||
System.out.println(xmlString);
|
System.out.println(xmlString);
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ public class SPListsTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testGetListName() throws Exception {
|
public void testGetListName() throws Exception {
|
||||||
SPLists instance = new SPLists(context);
|
SPLists instance = new SPLists(getContext());
|
||||||
String listName = instance.getListNameByTitle("Questionnaire");
|
String listName = instance.getListNameByTitle("Questionnaire");
|
||||||
assertEquals("Listname", "{4728157C-CFA4-447E-8863-170133FDC351}", listName);
|
assertEquals("Listname", "{4728157C-CFA4-447E-8863-170133FDC351}", listName);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -13,10 +15,13 @@ import org.junit.Test;
|
|||||||
*/
|
*/
|
||||||
public class SPUserGroupTest extends BaseTest {
|
public class SPUserGroupTest extends BaseTest {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LoggerFactory.getLogger(SPUserGroupTest.class.getName());
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore
|
||||||
public void testFromXML() throws Exception {
|
public void testFromXML() throws Exception {
|
||||||
String xmlString = readFileContentFromTest("usergroups/user.xml", "UTF-8");
|
String xmlString = readFileContentFromTest("usergroups/user.xml", "UTF-8");
|
||||||
SPUser user = new SPUser(context);
|
SPUser user = new SPUser(getContext());
|
||||||
assertNotNull(xmlString);
|
assertNotNull(xmlString);
|
||||||
user.setValue(xmlString);
|
user.setValue(xmlString);
|
||||||
}
|
}
|
||||||
@ -24,7 +29,7 @@ public class SPUserGroupTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testGetUserInfo() throws Exception {
|
public void testGetUserInfo() throws Exception {
|
||||||
SPUserGroup ug = new SPUserGroup(context);
|
SPUserGroup ug = new SPUserGroup(getContext());
|
||||||
String userId = ug.getUserId("wincor-nixdorf\\joern.muehlencord");
|
String userId = ug.getUserId("wincor-nixdorf\\joern.muehlencord");
|
||||||
assertEquals("Userid", "16", userId);
|
assertEquals("Userid", "16", userId);
|
||||||
}
|
}
|
||||||
@ -32,26 +37,47 @@ public class SPUserGroupTest extends BaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testAddUserToGroup() throws Exception {
|
public void testAddUserToGroup() throws Exception {
|
||||||
SPUserGroup ug = new SPUserGroup(context);
|
SPUserGroup ug = new SPUserGroup(getContext());
|
||||||
ug.addUserToGroup("wincor-nixdorf\\joern.muehlencord", "Test Group");
|
ug.addUserToGroup("wincor-nixdorf\\joern.muehlencord", "Test Group");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void testIsUserMemberOfGroup() throws Exception {
|
public void testIsUserMemberOfGroup() throws Exception {
|
||||||
SPUserGroup ug = new SPUserGroup(context);
|
SPUserGroup ug = new SPUserGroup(getContext());
|
||||||
boolean result = ug.isUserMemberOfGroup("wincor-nixdorf\\joern.muehlencord", "HQ All Members");
|
boolean result = ug.isUserMemberOfGroup("wincor-nixdorf\\joern.muehlencord", "HQ All Members");
|
||||||
assertEquals ("HQ All membership", true, result);
|
assertEquals("HQ All membership", true, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // Depends on available sharepoint currently
|
@Ignore // Depends on available sharepoint currently
|
||||||
public void getUserLoginNameFromEmail() throws Exception {
|
public void getUserLoginNameFromEmail() throws Exception {
|
||||||
SPUserGroup ug = new SPUserGroup(context);
|
SPUserGroup ug = new SPUserGroup(getContext());
|
||||||
SPUser user = ug.getUserFromEmail("joern.muehlencord@wincor-nixdorf.com");
|
SPUser user = ug.getUserFromEmail("joern.muehlencord@wincor-nixdorf.com");
|
||||||
assertEquals ("UserLogin", "wincor-nixdorf\\joern.muehlencord", user.getUserLoginName());
|
assertEquals("UserLogin", "wincor-nixdorf\\joern.muehlencord", user.getUserLoginName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
// @Ignore // Depends on available sharepoint currently
|
||||||
|
public void getUserFromEmail() throws Exception {
|
||||||
|
SPUserGroup ug = new SPUserGroup(getContext());
|
||||||
|
String user1Email = "nicole.cravo@wincor-nixdorf.com";
|
||||||
|
SPUser user1 = ug.getUserFromEmail(user1Email);
|
||||||
|
String user2Email = "joern.muehlencord@wincor-nixdorf.com";
|
||||||
|
SPUser user2 = ug.getUserFromEmail(user2Email);
|
||||||
|
|
||||||
|
|
||||||
|
LOGGER.info ("loginName1={}", user1.getUserLoginName());
|
||||||
|
LOGGER.info ("userId1={}", ug.getUserId(user1.getUserLoginName()));
|
||||||
|
LOGGER.info ("loginName2={}", user2.getUserLoginName());
|
||||||
|
LOGGER.info ("userId2={}", ug.getUserId(user2.getUserLoginName()));
|
||||||
|
// String userId1 = ug.getUserId(user1.getUserName());
|
||||||
|
// userId1 = user1.getUserID();
|
||||||
|
|
||||||
|
// SPUser user2 = ug.getUserFromEmail(email);
|
||||||
|
// assertNotNull (user2);
|
||||||
|
// String userId2 = user2.getUserID();
|
||||||
|
// assertEquals("userid", "wincor-nixdorf\\joern.muehlencord", userId2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
25
sharepoint/api/src/test/resources/log4j.xml
Normal file
25
sharepoint/api/src/test/resources/log4j.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||||
|
debug="true">
|
||||||
|
|
||||||
|
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c] %m%n" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<category name="de.muehlencord">
|
||||||
|
<priority value="TRACE"/>
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="com.wincornixdorf">
|
||||||
|
<priority value="DEBUG"/>
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<level value="INFO" />
|
||||||
|
<appender-ref ref="consoleAppender" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
||||||
Reference in New Issue
Block a user