tests/com/splunk/InputTest.java
for (Input input : inputs.refresh().values()) {
            final String inputName = input.getName();
            if (inputName.startsWith("delete-me")) {
                input.remove();
                assertEventuallyTrue(new EventuallyTrueBehavior() {
                    @Override
                    public boolean predicate() {
                        inputs.refresh();
                        return !inputs.containsKey(inputName);
void removeTestInputs()
tests/com/splunk/LicensePoolTest.java
LicensePoolCollection licensePoolCollection = service.getLicensePools();
        for (LicensePool licensePool : licensePoolCollection.values()) {
            testLicensePoolGetters(licensePool);
    
    private void testLicensePoolGetters(LicensePool licensePool) {
        licensePool.getDescription();
        licensePool.getQuota();
        licensePool.getSlaves();
        licensePool.getSlavesUsageBytes();
        licensePool.getStackId();
        licensePool.getUsedBytes();
void testLicensePoolGetters()
tests/com/splunk/MetadataTest.java
testMetadataGetters(service.getApplications());
        testMetadataGetters(service.getDeploymentClient());
        testMetadataGetters(service.getDeploymentServerClasses());
        testMetadataGetters(service.getDeploymentTenants());
        testMetadataGetters(service.getDistributedConfiguration());
        testMetadataGetters(service.getDistributedPeers());
        testMetadataGetters(service.getEventTypes());
        testMetadataGetters(service.getFiredAlertGroups());
        testMetadataGetters(service.getIndexes());
        testMetadataGetters(service.getInfo());
        testMetadataGetters(service.getInputs());
        testMetadataGetters(service.getJobs());
        testMetadataGetters(service.getLicenseGroups());
        testMetadataGetters(service.getLicensePools());
        testMetadataGetters(service.getLicenseSlaves());
        testMetadataGetters(service.getLicenseStacks());
        testMetadataGetters(service.getLicenses());
        testMetadataGetters(service.getLoggers());
        testMetadataGetters(service.getMessages());
        testMetadataGetters(service.getOutputDefault());
        testMetadataGetters(service.getOutputGroups());
        testMetadataGetters(service.getOutputServers());
        testMetadataGetters(service.getOutputSyslogs());
        testMetadataGetters(service.getPasswords());
        testMetadataGetters(service.getRoles());
        testMetadataGetters(service.getSavedSearches());
        testMetadataGetters(service.getSettings());
        testMetadataGetters(service.getUsers());
void testMetadataGettersOfDefaultEntities()

            EntityCollection<? extends Entity> entityCollection
tests/com/splunk/MetadataTest.java
for (Entity entity : entityCollection.values()) {
            testMetadataGetters(entity);
void testMetadataGetters(
            EntityCollection<? extends Entity> entityCollection)
tests/com/splunk/PasswordTest.java
for (Password password : service.getPasswords().values()) {
            testGettersOf(password);
void testGettersOfDefaultPasswords()
tests/com/splunk/SavedSearchTest.java
@Override
            public boolean predicate() {
                savedSearches.refresh();
                return !savedSearches.containsKey(savedSearchName);
new EventuallyTrueBehavior()
tests/com/splunk/SavedSearchTest.java
boolean isVisible = savedSearch.isVisible();
        savedSearch.setIsVisible(!isVisible);
                "rss,email,populate_lookup,script,summary_index");
        savedSearch.setSearch("search index=boris abcd");
        savedSearch.refresh();
        assertTrue(savedSearch.isActionEmail());
        assertTrue(savedSearch.isActionPopulateLookup());
        assertTrue(savedSearch.isActionRss());
        assertTrue(savedSearch.isActionScript());
        assertTrue(savedSearch.isActionSummaryIndex());
        assertTrue(savedSearch.isDigestMode());

        assertEquals("sdk-password", savedSearch.getActionEmailAuthPassword());
        assertEquals("sdk-username", savedSearch.getActionEmailAuthUsername());
        assertEquals("sdk-bcc@splunk.com", savedSearch.getActionEmailBcc());
        assertEquals("sdk-cc@splunk.com", savedSearch.getActionEmailCc());
        assertEquals("$name1$", savedSearch.getActionEmailCommand());
        assertEquals("text", savedSearch.getActionEmailFormat());
        assertEquals("sdk@splunk.com", savedSearch.getActionEmailFrom());
        assertEquals("dummy1.host.com", savedSearch.getActionEmailHostname());
        assertTrue(savedSearch.getActionEmailInline());
        assertEquals("splunk.com", savedSearch.getActionEmailMailServer());
        assertEquals(101, savedSearch.getActionEmailMaxResults());
        assertEquals("10s", savedSearch.getActionEmailMaxTime());
        assertEquals("dummy", savedSearch.getActionEmailPdfView());
        assertEquals("*", savedSearch.getActionEmailPreProcessResults());
        assertEquals("landscape", savedSearch.getActionEmailReportPaperOrientation());
        assertEquals("letter", savedSearch.getActionEmailReportPaperSize());
        assertFalse(savedSearch.getActionEmailReportServerEnabled());
        assertEquals("splunk.com", savedSearch.getActionEmailReportServerUrl());
        assertFalse(savedSearch.getActionEmailSendPdf());
        assertFalse(savedSearch.getActionEmailSendResults());
        assertEquals("sdk-subject", savedSearch.getActionEmailSubject());
        assertEquals("sdk-to@splunk.com", savedSearch.getActionEmailTo());
        assertFalse(savedSearch.getActionEmailTrackAlert());
        assertEquals("61", savedSearch.getActionEmailTtl());
        assertFalse(savedSearch.getActionEmailUseSsl());
        assertFalse(savedSearch.getActionEmailUseTls());
        assertFalse(savedSearch.getActionEmailWidthSortColumns());
        assertEquals("$name2$", savedSearch.getActionPopulateLookupCommand());
        assertEquals("dummypath", savedSearch.getActionPopulateLookupDest());
        assertEquals("dummy2.host.com", savedSearch.getActionPopulateLookupHostname());
        assertEquals(102, savedSearch.getActionPopulateLookupMaxResults());
        assertEquals("20s", savedSearch.getActionPopulateLookupMaxTime());
        assertFalse(savedSearch.getActionPopulateLookupTrackAlert());
        assertEquals("62", savedSearch.getActionPopulateLookupTtl());
        assertEquals("$name3$", savedSearch.getActionRssCommand());
        assertEquals("dummy3.host.com", savedSearch.getActionRssHostname());
        assertEquals(103, savedSearch.getActionRssMaxResults());
        assertEquals("30s", savedSearch.getActionRssMaxTime());
        assertFalse(savedSearch.getActionRssTrackAlert());
        assertEquals("63", savedSearch.getActionRssTtl());
        assertEquals("$name4$", savedSearch.getActionScriptCommand());
        assertEquals("dummy4.host.com", savedSearch.getActionScriptHostname());
        assertEquals(104, savedSearch.getActionScriptMaxResults());
        assertEquals("40s", savedSearch.getActionScriptMaxTime());
        assertFalse(savedSearch.getActionScriptTrackAlert());
        assertEquals("64", savedSearch.getActionScriptTtl());
        assertEquals("default", savedSearch.getActionSummaryIndexName());
        assertEquals("$name5$", savedSearch.getActionSummaryIndexCommand());
        assertEquals("dummy5.host.com", savedSearch.getActionSummaryIndexHostname());
        assertFalse(savedSearch.getActionSummaryIndexInline());
        assertEquals(105, savedSearch.getActionSummaryIndexMaxResults());
        assertEquals("50s", savedSearch.getActionSummaryIndexMaxTime());
        assertFalse(savedSearch.getActionSummaryIndexTrackAlert());
        assertEquals("65", savedSearch.getActionSummaryIndexTtl());
        assertEquals(savedSearch.isVisible(), !isVisible);
    @Test
    public void testUpdateWithBogusKeysFails() {
        try {
            Args args = new Args("borisTheMadBaboon", "Arrgh!");
            savedSearch.update(args);
            fail("Expected an exception.");
void testUpdate()
tests/com/splunk/SavedSearchTest.java
String newName = savedSearchName + "-alteration";
        try {
            Args args = new Args("name", newName);
            savedSearch.update(args);
            savedSearch.refresh();
            fail("Expected exception to be raised when trying to update name.");
void testCannotUpdateName()
tests/com/splunk/SavedSearchTest.java
final JobCollection jobs = service.getJobs();
        SavedSearchDispatchArgs args = new SavedSearchDispatchArgs();
        args.setDispatchBuckets(100);
        try {
            final Job job = savedSearch.dispatch(args);
            assertEventuallyTrue(new EventuallyTrueBehavior() {
                @Override
                public boolean predicate() {
                    return job.isReady();
void testDispatch()
tests/com/splunk/SavedSearchTest.java
final JobCollection jobs = service.getJobs();
        try {
            final Job job = savedSearch.dispatch();
            assertEventuallyTrue(new EventuallyTrueBehavior() {
                @Override
                public boolean predicate() {
                    return job.isReady();
void testDispatchWithoutOptions()
tests/com/splunk/SavedSearchTest.java
savedSearch.refresh();
        Job[] oldJobs = savedSearch.history();

        try {
            final Job job = savedSearch.dispatch();
            assertEventuallyTrue(new EventuallyTrueBehavior() {
                @Override
                public boolean predicate() {
                    return job.isReady();
void testHistory()
tests/com/splunk/ServiceTest.java
assertEquals(404, e.getStatus());
    @Test
    public void testInfo() throws Exception {
            assertTrue(info.containsKey(name));
    @Test
    public void testLogin() {
                (String) command.opts.get("host"),
                (Integer) command.opts.get("port"),
                (String) command.opts.get("scheme"));
            assertEquals(401, e.getStatus());
        service.login(
                (String) command.opts.get("username"),
                (String) command.opts.get("password"));
            assertEquals(401, e.getStatus());
    @Test
    public void testJobs() {
        for (Job entity : jobs.values())
            testGetters(entity);
        Job job = jobs.create("search *");
        testGetters(job);
    
    // Perform some non-intrusive inspection of the given Job object.
    private void testGetters(Job job) {
        ready(job);
        job.getDelegate();
        job.getDiskUsage();
        job.getDispatchState();
        job.getDoneProgress();
        job.getDropCount();
        job.getEarliestTime();
        job.getEventAvailableCount();
        job.getEventCount();
        job.getEventFieldCount();
        job.getEventIsStreaming();
        job.getEventIsTruncated();
        job.getEventSearch();
        job.getEventSorting();
        job.getKeywords();
        job.getLabel();
        job.getLatestTime();
        job.getNumPreviews();
        job.getPriority();
        job.getRemoteSearch();
        job.getReportSearch();
        job.getResultCount();
        job.getResultIsStreaming();
        job.getResultPreviewCount();
        job.getRunDuration();
        job.getScanCount();
        job.getSearch();
        job.getSearchEarliestTime();
        job.getSearchLatestTime();
        job.getSid();
        job.getStatusBuckets();
        job.getTtl();
        job.isDone();
        job.isFailed();
        job.isFinalized();
        job.isPaused();
        job.isPreviewEnabled();
        job.isRealTimeSearch();
        job.isSaved();
        job.isSavedSearch();
        job.isZombie();
        assertEquals(job.getName(), job.getSid());
void testGet()
tests/com/splunk/ServiceTest.java
// Save
        // Ensure setter updates local state
        assertEquals("sdk-host", settings.getHost());
        // Ensure update() merges arguments with local state
        settings.update(Args.create("minFreeSpace", 500));
        assertEquals("sdk-host2", settings.getHost());
        assertEquals(500, settings.getMinFreeSpace());
        // Ensure update argument takes precedence over local state
        settings.update(Args.create("minFreeSpace", 700));
        assertEquals(700, settings.getMinFreeSpace());

        // Restore
        {
            settings.setHost(originalHost);
            settings.setMinimumFreeSpace(originalMinSpace);
            settings.update();
            
            assertEquals(settings.getMinFreeSpace(),
                originalMinSpace);
            assertEquals(settings.getHost(), originalHost);
void testSettersAndGettersPattern()
tests/com/splunk/ServiceTest.java
assertFalse(users.containsKey(username));
        {
            args = new Args();
            args.put("password", password);
            args.put("roles", "power");
            user = users.create(username, args);
            
            assertTrue(users.containsKey(username));
            assertEquals(username, user.getName());
            assertEquals(1, user.getRoles().length);
            assertTrue(contains(user.getRoles(), "power"));
            
            users.remove(username);
            assertFalse(users.containsKey(username));
void testUsers()
tests/com/splunk/ServiceTest.java
@Test
    public void testNewServiceArgs() {
        assertEquals("Arg setters didn't replicate value to deprecated fields.",
            args.app, "myapp");
    @Test
    public void testNewServiceArgsAsMap() {
    @Test
    public void testNewServiceArgsWithDefaults() {
    
    // === Utility ===
    
    private static void checkResponse(ResponseMessage response) {
        assertEquals(200, response.getStatus());
        
        // Make sure we can at least load the Atom response
        AtomFeed.parseStream(response.getContent());
void testClassicServiceArgs()
Job job
tests/com/splunk/ServiceTest.java
while (!job.isReady()) {
            sleep(10);
Job ready(Job job)
tests/com/splunk/SettingsTest.java
void testGettersThrowNoExceptions()
int newHttpPort
tests/com/splunk/SettingsTest.java
Settings settings = service.getSettings();
        settings.setHttpPort(newHttpPort);
        settings.update();
        
        // If you change the splunkweb port, a new splunkweb instance
        // will be created on the new port. However the old splunkweb instance
        // will remain until you do a full restart.
        splunkRestart();
        waitForSplunkwebUp(newHttpPort);
        
        settings = service.getSettings();
        assertEquals(newHttpPort, settings.getHttpPort());
void changeHttpPort(int newHttpPort)
final int httpPort
tests/com/splunk/SettingsTest.java
// Wait for splunkweb to come back up
        assertEventuallyTrue(new EventuallyTrueBehavior() {
            {
                tries = 20;
                pauseTime = 1000;
void waitForSplunkwebUp(final int httpPort)
tests/com/splunk/SettingsTest.java
return isPortInUse(httpPort);
boolean predicate()
int port
tests/com/splunk/SettingsTest.java
try {
            Socket pingSocket = new Socket("127.0.0.1", port);
            pingSocket.close();
            if (VERBOSE_PORT_SCAN) {
                System.out.println("IN-USE(" + port + ")");
boolean isPortInUse(int port)
tests/com/splunk/UploadTest.java
String osName = service.getInfo().getOsName();
        if (osName.equals("Windows")) {
void testOneshot()
tests/com/splunk/InputTest.java
boolean matches = InputCollection.matchesInputName(InputKind.Tcp, "1-[]bc", "def");
        SplunkTestCase.assertFalse(matches);
        matches = InputCollection.matchesInputName(InputKind.Tcp, "1-[]bc", "1-[]bc");
        SplunkTestCase.assertTrue(matches);
void testMatchNonscriptInputName()
tests/com/splunk/InputTest.java
SplunkTestCase.assertTrue(InputCollection.matchesInputName(
                InputKind.Script, "abc.py", "$SPLUNK_HOME/etc/apps/boris/bin/abc.py"
        ));
        SplunkTestCase.assertFalse(InputCollection.matchesInputName(
                InputKind.Script, "abc", "$SPLUNK_HOME/etc/apps/boris/bin/abc.py"
        ));
void testMatchScriptInputName()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputs = service.getInputs();

        Set<InputKind> kinds = inputs.getInputKinds();
        boolean hasTest2 = false;
        for (InputKind ik : kinds) {
            if (ik.getKind() == "test2") {
                hasTest2 = true;
void testInputKinds()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputs = service.getInputs();

        SplunkTestCase.assertFalse(inputs.isEmpty());
        boolean hasAbcd = inputs.containsKey("abcd");
        if (!hasAbcd) {
            Args args = new Args();
            args.add("field1", "boris");
            inputs.create("abcd", InputKind.create("test2"), args);
void testListInputs()
Input input
tests/com/splunk/InputTest.java
InputKind inputKind = input.getKind();
        TcpConnections tcpConnections = null;
        UdpConnections udpConnections = null;

        if (inputKind == InputKind.Monitor) {
            MonitorInput monitorInput = (MonitorInput) input;
            monitorInput.getBlacklist();
            monitorInput.getCrcSalt();
            monitorInput.getFileCount();
            monitorInput.getFollowTail();
            monitorInput.getHost();
            monitorInput.getHostRegex();
            monitorInput.getIgnoreOlderThan();
            monitorInput.getIndex();
            monitorInput.getQueue();
            monitorInput.getRcvBuf();
            monitorInput.getRecursive();
            monitorInput.getSource();
            monitorInput.getSourceType();
            monitorInput.getTimeBeforeClose();
            monitorInput.getWhitelist();
void touchSpecificInput(Input input)
inputKind == InputKind.Script
tests/com/splunk/InputTest.java
ScriptInput scriptInput = (ScriptInput) input;
            scriptInput.getEndTime();
            scriptInput.getGroup();
            scriptInput.getHost();
            scriptInput.getIndex();
            scriptInput.getInterval();
            scriptInput.getRcvBuf();
            scriptInput.getStartTime();
else if (inputKind == InputKind.Script)
inputKind == InputKind.Tcp
tests/com/splunk/InputTest.java
TcpInput tcpInput = (TcpInput) input;
            tcpInput.getConnectionHost();
            tcpInput.getGroup();
            tcpInput.getHost();
            tcpInput.getIndex();
            tcpInput.getQueue();
            tcpInput.getRcvBuf();
            tcpInput.getRestrictToHost();
            tcpInput.getSource();
            tcpInput.getSourceType();
            tcpInput.getSSL();
            tcpConnections = tcpInput.connections();
            tcpConnections.getConnection();
            tcpConnections.getServername();
else if (inputKind == InputKind.Tcp)
inputKind == InputKind.TcpSplunk
tests/com/splunk/InputTest.java
TcpSplunkInput tcpSplunkInput = (TcpSplunkInput) input;
            tcpSplunkInput.getConnectionHost();
            tcpSplunkInput.getGroup();
            tcpSplunkInput.getHost();
            tcpSplunkInput.getIndex();
            tcpSplunkInput.getQueue();
            tcpSplunkInput.getRcvBuf();
            tcpSplunkInput.getSource();
            tcpSplunkInput.getSourceType();
            tcpSplunkInput.getSSL();
            tcpConnections = tcpSplunkInput.connections();
            tcpConnections.getConnection();
            tcpConnections.getServername();
else if (inputKind == InputKind.TcpSplunk)
inputKind == InputKind.Udp
tests/com/splunk/InputTest.java
UdpInput udpInput = (UdpInput) input;
            udpInput.getConnectionHost();
            udpInput.getGroup();
            udpInput.getHost();
            udpInput.getIndex();
            udpInput.getQueue();
            udpInput.getRcvBuf();
            udpInput.getSource();
            udpInput.getSourceType();
            udpInput.getNoAppendingTimeStamp();
            udpInput.getNoPriorityStripping();
            udpConnections = udpInput.connections();
            udpConnections.getGroup();
else if (inputKind == InputKind.Udp)
inputKind == InputKind.WindowsActiveDirectory
tests/com/splunk/InputTest.java
WindowsActiveDirectoryInput windowsActiveDirectoryInput =
                    (WindowsActiveDirectoryInput) input;
            windowsActiveDirectoryInput.getIndex();
            windowsActiveDirectoryInput.getMonitorSubtree();
            windowsActiveDirectoryInput.getStartingNode();
            windowsActiveDirectoryInput.getTargetDc();
else if (inputKind == InputKind.WindowsActiveDirectory)
inputKind == InputKind.WindowsEventLog
tests/com/splunk/InputTest.java
WindowsEventLogInput windowsEventLogInput =
                    (WindowsEventLogInput) input;
            windowsEventLogInput.getHosts();
            windowsEventLogInput.getIndex();
            windowsEventLogInput.getLocalName();
            windowsEventLogInput.getLogs();
            windowsEventLogInput.getLookupHost();
else if (inputKind == InputKind.WindowsEventLog)
inputKind == InputKind.WindowsPerfmon
tests/com/splunk/InputTest.java
WindowsPerfmonInput windowsPerfmonInput =
                    (WindowsPerfmonInput) input;
            windowsPerfmonInput.getCounters();
            windowsPerfmonInput.getIndex();
            windowsPerfmonInput.getInstances();
            windowsPerfmonInput.getInterval();
            windowsPerfmonInput.getObject();
else if (inputKind == InputKind.WindowsPerfmon)
inputKind == InputKind.WindowsRegistry
tests/com/splunk/InputTest.java
WindowsRegistryInput windowsRegistryInput =
                    (WindowsRegistryInput) input;
            windowsRegistryInput.getBaseline();
            windowsRegistryInput.getHive();
            windowsRegistryInput.getIndex();
            windowsRegistryInput.getMonitorSubnodes();
            windowsRegistryInput.getProc();
            windowsRegistryInput.getType();
else if (inputKind == InputKind.WindowsRegistry)
inputKind == InputKind.WindowsWmi
tests/com/splunk/InputTest.java
WindowsWmiInput windowsWmiInput = (WindowsWmiInput) input;
            windowsWmiInput.getClasses();
            windowsWmiInput.getFields();
            windowsWmiInput.getIndex();
            windowsWmiInput.getInstances();
            windowsWmiInput.getInterval();
            windowsWmiInput.getLocalName();
            windowsWmiInput.getLookupHost();
            windowsWmiInput.getServers();
            windowsWmiInput.getWql();
else if (inputKind == InputKind.WindowsWmi)
tests/com/splunk/InputTest.java
Service service = connect();

        InputCollection inputs = service.getInputs();

        // Iterate inputs and make sure we can read them.
        for (Input input : inputs.values()) {
            input.getName();
            input.getTitle();
            input.getPath();
            input.getKind();
            touchSpecificInput(input);
void testInputs()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        ServiceInfo info = service.getInfo();

        // CRUD Monitor input
        String filename;
        if (info.getOsName().equals("Windows"))
            filename = "C:\\Windows\\WindowsUpdate.log";
        else if (info.getOsName().equals("Linux"))
            filename = "/var/log/messages";
        else if (info.getOsName().equals("Darwin")) {
            filename = "/var/log/system.log";
void testMonitorInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        ServiceInfo info = service.getInfo();

        // CRUD Script input
        String filename;
        if (info.getOsName().equals("Windows"))
            filename = "echo.bat";
        else
            filename = "echo.sh";

        Args args = new Args();
        args.clear();
        args.put("interval", "60");
        if (inputCollection.get(filename) != null) {
            inputCollection.remove(filename);
void testScriptInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        String port = "9999"; // test port

        // CRUD TCP (raw) input
        if (inputCollection.containsKey(port)) {
            inputCollection.remove(port);
            inputCollection.refresh();
void testTcpInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        String port = "9998"; // test port

        // CRUD TCP (cooked) input
        if (inputCollection.containsKey(port)) {
            inputCollection.remove(port);
            inputCollection.refresh();
void testTcpSplunkInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        String port = "9997"; // test port

        // CRUD UDP input
        if (inputCollection.containsKey(port)) {
            inputCollection.remove(port);
            inputCollection.refresh();
void testUdpInputCrud()
tests/com/splunk/InputTest.java
/*
     * Need an active directory domain controller for Windows Active Directory
     *

        Service service = connect();
        InputCollection inputCollection = service.getInputs();
        ServiceInfo info = service.getInfo();

        if (info.getOsName().equals("Windows")) {
            String name = "sdk-input-wad";
            Args args = new Args();

            if (inputCollection.containsKey(name)) {
                inputCollection.remove(name);
                inputCollection.refresh();
void testWindowsActiveDirectoryInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        ServiceInfo info = service.getInfo();

        if (info.getOsName().equals("Windows")) {
            String name = "sdk-input-wel";
            Args args = new Args();

            if (inputCollection.containsKey(name)) {
                inputCollection.remove(name);
                inputCollection.refresh();
void testWindowsEventLogInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        ServiceInfo info = service.getInfo();

        if (info.getOsName().equals("Windows")) {
            String name = "sdk-input-wp";
            Args args = new Args();

            if (inputCollection.containsKey(name)) {
                inputCollection.remove(name);
                inputCollection.refresh();
void testWindowsPerfmonInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        ServiceInfo info = service.getInfo();

        if (info.getOsName().equals("Windows")) {
            String name = "sdk-input-wr";
            Args args = new Args();

            if (service.versionCompare("4.3") < 0)
                return;

            if (inputCollection.containsKey(name)) {
                inputCollection.remove(name);
                inputCollection.refresh();
            assertFalse(assertRoot + "#71", inputCollection.containsKey(name));

            // CRUD Windows Registry Input
            args.put("disabled", true);
            args.put("baseline", false);
            args.put("hive", "HKEY_USERS");
            args.put("proc", "*");
            args.put("type", "*");
            inputCollection.create(name, InputKind.WindowsRegistry, args);
            assertTrue(assertRoot + "#72", inputCollection.containsKey(name));
            WindowsRegistryInput windowsRegistryInput =
                    (WindowsRegistryInput)inputCollection.get(name);

            windowsRegistryInput.setIndex("main");
            windowsRegistryInput.setMonitorSubnodes(true);
            windowsRegistryInput.update();

            assertFalse(assertRoot + "#73", windowsRegistryInput.getBaseline());
            assertEquals(assertRoot + "#74", "main",
                windowsRegistryInput.getIndex());

            // adjust a few of the arguments
            String[] wriType = {"create", "delete"
void testWindowsRegistryInputCrud()
tests/com/splunk/InputTest.java
Service service = connect();
        InputCollection inputCollection = service.getInputs();
        ServiceInfo info = service.getInfo();

        if (info.getOsName().equals("Windows")) {
            String name = "sdk-input-wmi";
            Args args = new Args();

            if (inputCollection.containsKey(name)) {
                inputCollection.remove(name);
                inputCollection.refresh();
void testWmiInputCrud()
LicensePool licensePool
tests/com/splunk/LicensePoolTest.java
licensePool.getDescription();
        licensePool.getQuota();
        licensePool.getSlaves();
        licensePool.getSlavesUsageBytes();
        licensePool.getStackId();
        licensePool.getUsedBytes();
void checkLicensePool(LicensePool licensePool)
LicensePoolCollection licensePoolCollection
tests/com/splunk/LicensePoolTest.java
for (LicensePool licensePool : licensePoolCollection.values())
            checkLicensePool(licensePool);
void checkLicensePools(LicensePoolCollection licensePoolCollection)
Entity entity
tests/com/splunk/MetadataTest.java
void checkMetadata(EntityCollection entityCollection) {
        for (Object entity : entityCollection.values())
            checkMetadata((Entity)entity);
void checkMetadata(Entity entity)
tests/com/splunk/MetadataTest.java
Service service = connect();

        checkMetadata(service.getApplications());
        checkMetadata(service.getDeploymentClient());
        checkMetadata(service.getDeploymentServerClasses());
        checkMetadata(service.getDeploymentTenants());
        checkMetadata(service.getDistributedConfiguration());
        checkMetadata(service.getDistributedPeers());
        checkMetadata(service.getEventTypes());
        checkMetadata(service.getFiredAlertGroups());
        checkMetadata(service.getIndexes());
        checkMetadata(service.getInfo());
        checkMetadata(service.getInputs());
        checkMetadata(service.getJobs());
        checkMetadata(service.getLicenseGroups());
        checkMetadata(service.getLicensePools());
        checkMetadata(service.getLicenseSlaves());
        checkMetadata(service.getLicenseStacks());
        checkMetadata(service.getLicenses());
        checkMetadata(service.getLoggers());
        checkMetadata(service.getMessages());
        checkMetadata(service.getOutputDefault());
        checkMetadata(service.getOutputGroups());
        checkMetadata(service.getOutputServers());
        checkMetadata(service.getOutputSyslogs());
        checkMetadata(service.getPasswords());
        checkMetadata(service.getRoles());
        checkMetadata(service.getSavedSearches());
        checkMetadata(service.getSettings());
        checkMetadata(service.getUsers());
void testMetadata()
Password password
tests/com/splunk/PasswordTest.java
@Test public void testPasswords() {
        Service service = connect();
        for (Password password : service.getPasswords().values())
            checkPassword(password);
void checkPassword(Password password)
tests/com/splunk/SavedSearchTest.java
Service service = connect();
        SavedSearchCollection savedSearches = service.getSavedSearches();
        // Iterate saved searches and make sure we can read them.
        for (SavedSearch savedSearch : savedSearches.values()) {
            // Resource properties
            savedSearch.getName();
            savedSearch.getTitle();
            savedSearch.getPath();
            // SavedSearch properties get
            savedSearch.getActionEmailAuthPassword();
            savedSearch.getActionEmailAuthUsername();
            savedSearch.getActionEmailSendResults();
            savedSearch.getActionEmailBcc();
            savedSearch.getActionEmailCc();
            savedSearch.getActionEmailCommand();
            savedSearch.getActionEmailFormat();
            savedSearch.getActionEmailInline();
            savedSearch.getActionEmailMailServer();
            savedSearch.getActionEmailMaxResults();
            savedSearch.getActionEmailMaxTime();
            savedSearch.getActionEmailReportPaperOrientation();
            savedSearch.getActionEmailReportPaperSize();
            savedSearch.getActionEmailReportServerEnabled();
            savedSearch.getActionEmailReportServerUrl();
            savedSearch.getActionEmailSendPdf();
            savedSearch.getActionEmailSendResults();
            savedSearch.getActionEmailSubject();
            savedSearch.getActionEmailTo();
            savedSearch.getActionEmailTrackAlert();
            savedSearch.getActionEmailTtl();
            savedSearch.getActionEmailUseSsl();
            savedSearch.getActionEmailUseTls();
            savedSearch.getActionEmailWidthSortColumns();
            savedSearch.getActionPopulateLookupCommand();
            savedSearch.getActionPopulateLookupDest();
            savedSearch.getActionPopulateLookupHostname();
            savedSearch.getActionPopulateLookupMaxResults();
            savedSearch.getActionPopulateLookupMaxTime();
            savedSearch.getActionPopulateLookupTrackAlert();
            savedSearch.getActionPopulateLookupTtl();
            savedSearch.getActionRssCommand();
            savedSearch.getActionRssHostname();
            savedSearch.getActionRssMaxResults();
            savedSearch.getActionRssMaxTime();
            savedSearch.getActionRssTrackAlert();
            savedSearch.getActionRssTtl();
            savedSearch.getActionScriptCommand();
            savedSearch.getActionScriptFilename();
            savedSearch.getActionScriptHostname();
            savedSearch.getActionScriptMaxResults();
            savedSearch.getActionScriptMaxTime();
            savedSearch.getActionScriptTrackAlert();
            savedSearch.getActionScriptTtl();
            savedSearch.getActionSummaryIndexName();
            savedSearch.getActionSummaryIndexCommand();
            savedSearch.getActionSummaryIndexHostname();
            savedSearch.getActionSummaryIndexInline();
            savedSearch.getActionSummaryIndexMaxResults();
            savedSearch.getActionSummaryIndexMaxTime();
            savedSearch.getActionSummaryIndexTrackAlert();
            savedSearch.getActionSummaryIndexTtl();
            savedSearch.getAlertDigestMode();
            savedSearch.getAlertExpires();
            savedSearch.getAlertSeverity();
            savedSearch.getAlertSuppress();
            savedSearch.getAlertSuppressFields();
            savedSearch.getAlertSuppressPeriod();
            savedSearch.getAlertTrack();
            savedSearch.getAlertComparator();
            savedSearch.getAlertCondition();
            savedSearch.getAlertThreshold();
            savedSearch.getAlertType();
            savedSearch.getCronSchedule();
            savedSearch.getDescription();
            savedSearch.getDispatchBuckets();
            savedSearch.getDispatchEarliestTime();
            savedSearch.getDispatchLatestTime();
            savedSearch.getDispatchLookups();
            savedSearch.getDispatchMaxCount();
            savedSearch.getDispatchMaxTime();
            savedSearch.getDispatchReduceFreq();
            savedSearch.getDispatchRtBackfill();
            savedSearch.getDispatchSpawnProcess();
            savedSearch.getDispatchTimeFormat();
            savedSearch.getDispatchTtl();
            savedSearch.getDisplayView();
            savedSearch.getMaxConcurrent();
            savedSearch.getNextScheduledTime();
            savedSearch.getQualifiedSearch();
            savedSearch.getRealtimeSchedule();
            savedSearch.getRequestUiDispatchApp();
            savedSearch.getRequestUiDispatchView();
            savedSearch.getRestartOnSearchPeerAdd();
            savedSearch.getRunOnStartup();
            savedSearch.getSearch();
            savedSearch.getVsid();
            savedSearch.isActionEmail();
            savedSearch.isActionPopulateLookup();
            savedSearch.isActionRss();
            savedSearch.isActionScript();
            savedSearch.isActionSummaryIndex();
            savedSearch.isDigestMode();
            savedSearch.isDisabled();
            savedSearch.isScheduled();
            savedSearch.isVisible();
void testSavedSearches()
tests/com/splunk/SavedSearchTest.java
Service service = connect();

        SavedSearchCollection savedSearches = service.getSavedSearches();

        // Ensure test starts in a known good state
        if (savedSearches.containsKey("sdk-test1"))
            savedSearches.remove("sdk-test1");
        assertFalse(assertRoot + "#1", savedSearches.containsKey("sdk-test1"));

        SavedSearch savedSearch;
        String search = "search index=sdk-tests * earliest=-1m";

        // Create a saved search
        savedSearches.create("sdk-test1", search);
        assertTrue(assertRoot + "#2", savedSearches.containsKey("sdk-test1"));

        // Read the saved search
        savedSearch = savedSearches.get("sdk-test1");
        assertTrue(assertRoot + "#3", savedSearch.isVisible());
        // CONSIDER: Test some additinal default property values.

        // Update search properties, but don't specify required args to test
        // pulling them from the existing object
        savedSearch.update(new Args("is_visible", false));
        savedSearch.refresh();
        assertFalse(assertRoot + "#4", savedSearch.isVisible());
        // Delete the saved search
        savedSearches.remove("sdk-test1");
        assertFalse(assertRoot + "#5", savedSearches.containsKey("sdk-test1"));
        // Create a saved search with some additional arguments
        savedSearch = savedSearches.create(
            "sdk-test1", search, new Args("is_visible", false));
        assertFalse(assertRoot + "#6", savedSearch.isVisible());
        // set email params
        //savedSearch.setActionScriptFilename(String  filename);
            "rss,email,populate_lookup,script,summary_index");
        savedSearch.setSearch(search);
        // check
        assertTrue(assertRoot + "#7", savedSearch.isActionEmail());
        assertTrue(assertRoot + "#8", savedSearch.isActionPopulateLookup());
        assertTrue(assertRoot + "#9", savedSearch.isActionRss());
        assertTrue(assertRoot + "#10", savedSearch.isActionScript());
        assertTrue(assertRoot + "#11", savedSearch.isActionSummaryIndex());
        assertTrue(assertRoot + "#12", savedSearch.isDigestMode());

        assertEquals(assertRoot + "#12", "sdk-password",
            savedSearch.getActionEmailAuthPassword());
        assertEquals(assertRoot + "#13", "sdk-username",
            savedSearch.getActionEmailAuthUsername());
        assertEquals(assertRoot + "#14", "sdk-bcc@splunk.com",
            savedSearch.getActionEmailBcc());
        assertEquals(assertRoot + "#15", "sdk-cc@splunk.com",
            savedSearch.getActionEmailCc());
        assertEquals(assertRoot + "#16", "$name1$",
            savedSearch.getActionEmailCommand());
        assertEquals(assertRoot + "#17", "text",
            savedSearch.getActionEmailFormat());
        assertEquals(assertRoot + "#18", "sdk@splunk.com",
            savedSearch.getActionEmailFrom());
        assertEquals(assertRoot + "#19", "dummy1.host.com",
            savedSearch.getActionEmailHostname());
        assertTrue(assertRoot + "#20", savedSearch.getActionEmailInline());
        assertEquals(assertRoot + "#21", "splunk.com",
            savedSearch.getActionEmailMailServer());
        assertEquals(assertRoot + "#22", 101,
            savedSearch.getActionEmailMaxResults());
        assertEquals(assertRoot + "#23", "10s",
            savedSearch.getActionEmailMaxTime());
        assertEquals(assertRoot + "#24", "dummy",
            savedSearch.getActionEmailPdfView());
        assertEquals(assertRoot + "#25", "*",
            savedSearch.getActionEmailPreProcessResults());
        assertEquals(assertRoot + "#26", "landscape",
            savedSearch.getActionEmailReportPaperOrientation());
        assertEquals(assertRoot + "#27", "letter",
            savedSearch.getActionEmailReportPaperSize());
        assertFalse(assertRoot + "#28",
            savedSearch.getActionEmailReportServerEnabled());
        assertEquals(assertRoot + "#29", "splunk.com",
            savedSearch.getActionEmailReportServerUrl());
        assertFalse(assertRoot + "#30", savedSearch.getActionEmailSendPdf());
        assertFalse(assertRoot + "#31",
            savedSearch.getActionEmailSendResults());
        assertEquals(assertRoot + "#32", "sdk-subject",
            savedSearch.getActionEmailSubject());
        assertEquals(assertRoot + "#33", "sdk-to@splunk.com",
            savedSearch.getActionEmailTo());
        assertFalse(assertRoot + "#34", savedSearch.getActionEmailTrackAlert());
        assertEquals(assertRoot + "#35", "61", savedSearch.getActionEmailTtl());
        assertFalse(assertRoot + "#36", savedSearch.getActionEmailUseSsl());
        assertFalse(assertRoot + "#37", savedSearch.getActionEmailUseTls());
        assertFalse(assertRoot + "#38",
            savedSearch.getActionEmailWidthSortColumns());
        assertEquals(assertRoot + "#39", "$name2$",
            savedSearch.getActionPopulateLookupCommand());
        assertEquals(assertRoot + "#40", "dummypath",
            savedSearch.getActionPopulateLookupDest());
        assertEquals(assertRoot + "#41", "dummy2.host.com",
            savedSearch.getActionPopulateLookupHostname());
        assertEquals(assertRoot + "#42", 102,
            savedSearch.getActionPopulateLookupMaxResults());
        assertEquals(assertRoot + "#43", "20s",
            savedSearch.getActionPopulateLookupMaxTime());
        assertFalse(assertRoot + "#44",
            savedSearch.getActionPopulateLookupTrackAlert());
        assertEquals(assertRoot + "#45", "62",
            savedSearch.getActionPopulateLookupTtl());
        assertEquals(assertRoot + "#46", "$name3$",
            savedSearch.getActionRssCommand());
        assertEquals(assertRoot + "#47", "dummy3.host.com",
            savedSearch.getActionRssHostname());
        assertEquals(assertRoot + "#48", 103,
            savedSearch.getActionRssMaxResults());
        assertEquals(assertRoot + "#49", "30s",
            savedSearch.getActionRssMaxTime());
        assertFalse(assertRoot + "#50", savedSearch.getActionRssTrackAlert());
        assertEquals(assertRoot + "#51", "63", savedSearch.getActionRssTtl());
        assertEquals(assertRoot + "#52", "$name4$",
            savedSearch.getActionScriptCommand());
        //savedSearch.setActionScriptFilename(String  filename);
        assertEquals(assertRoot + "#53", "dummy4.host.com",
            savedSearch.getActionScriptHostname());
        assertEquals(assertRoot + "#54", 104,
            savedSearch.getActionScriptMaxResults());
        assertEquals(assertRoot + "#55", "40s",
            savedSearch.getActionScriptMaxTime());
        assertFalse(assertRoot + "#56",
            savedSearch.getActionScriptTrackAlert());
        assertEquals(assertRoot + "#57", "64",
            savedSearch.getActionScriptTtl());
        assertEquals(assertRoot + "#58", "default",
            savedSearch.getActionSummaryIndexName());
        assertEquals(assertRoot + "#59", "$name5$",
            savedSearch.getActionSummaryIndexCommand());
        assertEquals(assertRoot + "#60", "dummy5.host.com",
            savedSearch.getActionSummaryIndexHostname());
        assertFalse(assertRoot + "#61",
            savedSearch.getActionSummaryIndexInline());
        assertEquals(assertRoot + "#62", 105,
            savedSearch.getActionSummaryIndexMaxResults());
        assertEquals(assertRoot + "#63", "50s",
            savedSearch.getActionSummaryIndexMaxTime());
        assertFalse(assertRoot + "#64",
            savedSearch.getActionSummaryIndexTrackAlert());
        assertEquals(assertRoot + "#65", "65",
            savedSearch.getActionSummaryIndexTtl());

        // Delete the saved search - using alternative method
        savedSearch.remove();
        savedSearches.refresh();
        assertFalse(assertRoot + "#66", savedSearches.containsKey("sdk-test1"));
    @Test public void testDispatch() throws IOException, InterruptedException {
        Service service = connect();

        SavedSearchCollection savedSearches = service.getSavedSearches();

        // Ensure test starts in a known good state
        if (savedSearches.containsKey("sdk-test1"))
            savedSearches.remove("sdk-test1");
        assertFalse(assertRoot + "#67", savedSearches.containsKey("sdk-test1"));

        String search = "search index=sdk-tests * earliest=-1m";

        // Create a saved search
        SavedSearch savedSearch = savedSearches.create("sdk-test1", search);

        Job job;

        // Dispatch the saved search and wait for results.
        job = savedSearch.dispatch();
        wait(job);
        job.getResults().close();
        job.cancel();

        // Dispatch with some additional search options
        job = savedSearch.dispatch(new Args("dispatch.buckets", 100));
        wait(job);
        job.getTimeline().close();
        job.cancel();

        // Delete the saved search
        savedSearches.remove("sdk-test1");
        assertFalse(assertRoot + "#68", savedSearches.containsKey("sdk-test1"));
    
    @Test public void testDispatchWithAbsoluteTimeArg() throws IOException, InterruptedException {
        Service service = connect();

        SavedSearchCollection savedSearches = service.getSavedSearches();

        // Ensure test starts in a known good state
        if (savedSearches.containsKey("sdk-test1"))
            savedSearches.remove("sdk-test1");
        assertFalse(assertRoot + "#67", savedSearches.containsKey("sdk-test1"));
        String search = "search index=sdk-tests * earliest=-1m";

        // Create a saved search
        SavedSearch savedSearch = savedSearches.create("sdk-test1", search);
        
        Calendar c = new GregorianCalendar();
        c.setTime(new Date());
        c.add(Calendar.MINUTE, -2);
        Date expectedTime = c.getTime();
        
        SavedSearchDispatchArgs dispatchArgs = new SavedSearchDispatchArgs();
        dispatchArgs.setDispatchEarliestTime(expectedTime);

        // Dispatch the saved search and check job properties
        Job job = savedSearch.dispatch(dispatchArgs);
        ready(job);
        Date actualTime = job.getEarliestTime();
        
        boolean nearlyEqual = actualTime.toString().equals(expectedTime.toString());
        assertTrue(actualTime + " != " + expectedTime, nearlyEqual);
    
    @Test public void testDispatchWithRelativeTimeArg() throws IOException, InterruptedException {
        Service service = connect();

        SavedSearchCollection savedSearches = service.getSavedSearches();
        // Ensure test starts in a known good state
        if (savedSearches.containsKey("sdk-test1"))
            savedSearches.remove("sdk-test1");
        assertFalse(assertRoot + "#67", savedSearches.containsKey("sdk-test1"));
        String search = "search index=sdk-tests * earliest=-1m";
        // Create a saved search
        SavedSearch savedSearch = savedSearches.create("sdk-test1", search);
        
        String expectedTimeString = "-2m";
        
        Calendar c = new GregorianCalendar();
        c.setTime(new Date());
        c.add(Calendar.MINUTE, -2);
        Date expectedTime = c.getTime();
        
        SavedSearchDispatchArgs dispatchArgs = new SavedSearchDispatchArgs();
        dispatchArgs.setDispatchEarliestTime(expectedTimeString);
        // Dispatch the saved search and check job properties
        Job job = savedSearch.dispatch(dispatchArgs);
        ready(job);
        Date actualTime = job.getEarliestTime();
        
        boolean nearlyEqual = actualTime.toString().equals(expectedTime.toString());
        assertTrue(actualTime + " != " + expectedTime, nearlyEqual);
void testSavedSearchCrud()
Job job
tests/com/splunk/ServiceTest.java
ready(job);
        job.getDelegate();
        job.getDiskUsage();
        job.getDispatchState();
        job.getDoneProgress();
        job.getDropCount();
        job.getEarliestTime();
        job.getEventAvailableCount();
        job.getEventCount();
        job.getEventFieldCount();
        job.getEventIsStreaming();
        job.getEventIsTruncated();
        job.getEventSearch();
        job.getEventSorting();
        job.getKeywords();
        job.getLabel();
        job.getLatestTime();
        job.getNumPreviews();
        job.getPriority();
        job.getRemoteSearch();
        job.getReportSearch();
        job.getResultCount();
        job.getResultIsStreaming();
        job.getResultPreviewCount();
        job.getRunDuration();
        job.getScanCount();
        job.getSearch();
        job.getSearchEarliestTime();
        job.getSearchLatestTime();
        job.getSid();
        job.getStatusBuckets();
        job.getTtl();
        job.isDone();
        job.isFailed();
        job.isFinalized();
        job.isPaused();
        job.isPreviewEnabled();
        job.isRealTimeSearch();
        job.isSaved();
        job.isSavedSearch();
        job.isZombie();
        assertEquals(assertRoot + "#1", job.getName(), job.getSid());
void checkJob(Job job)
ResponseMessage response
tests/com/splunk/ServiceTest.java
assertEquals(assertRoot + "#2", 200, response.getStatus());
        try {
            // Make sure we can at least load the Atom response
            AtomFeed.parseStream(response.getContent());
void checkResponse(ResponseMessage response)
tests/com/splunk/ServiceTest.java
Service service = connect();

            assertEquals(assertRoot + "#4", 404, e.getStatus());
    @Test public void testInfo() throws Exception {
        Service service = connect();

            assertTrue(assertRoot + "#5", info.containsKey(name));
    @Test public void testLogin() {
            command.host, 
            command.port, 
            command.scheme);
            assertEquals(assertRoot + "#6", 401, e.getStatus());
        service.login(command.username, command.password);
            assertEquals(assertRoot + "#7", 401, e.getStatus());
    @Test public void testRestart() throws Exception {
        splunkRestart();
void testGet()
tests/com/splunk/ServiceTest.java
Job job;

        Service service = connect();

        for (Entity entity : jobs.values())
            checkJob((Job)entity);
        job = jobs.create("search *");
        checkJob(job);
    @Test public void testSettersAndGetters() {

        // The individual classes test most of the set/get methods,
        // but call out some specific cases here.

        Service service = connect();
        // make sure set updates state before getting.
        // entity.setMethod(value)
        // entity.getMethod() --> gets value.
        assertEquals(assertRoot + "#8", "sdk-host", settings.getHost());
        // make sure posts arguments are merged
        // entity.setMethod(value)
        // entity.update(args.create("key2", value2))
        settings.update(
            new HashMap<String, Object>(Args.create("minFreeSpace", 500)));
        assertEquals(assertRoot + "#9", "sdk-host2", settings.getHost());
        assertEquals(assertRoot + "#10", 500, settings.getMinFreeSpace());
        // make sure live posts argument take precedents over setters
        // entity.setMethod(value)
        // entity.update(args.create("samekey", value2))
        settings.update(
            new HashMap<String, Object>(Args.create("minFreeSpace", 700)));
        assertEquals(assertRoot + "#11", 700, settings.getMinFreeSpace());

        // Restore original
        settings.setHost(originalHost);
        settings.setMinimumFreeSpace(originalMinSpace);
        settings.update();
        assertEquals(assertRoot + "#12", settings.getMinFreeSpace(),
            originalMinSpace);
        assertEquals(assertRoot + "#13", settings.getHost(), originalHost);
    @Test public void testUsers() {
        Service service = connect();

        assertFalse(assertRoot + "#14", users.containsKey(username));
        args = new Args();
        args.put("password", password);
        args.put("roles", "power");
        user = users.create(username, args);
        assertTrue(assertRoot + "#15", users.containsKey(username));
        assertEquals(assertRoot + "#16", username, user.getName());
        assertEquals(assertRoot + "#17", 1, user.getRoles().length);
        assertTrue(assertRoot + "#18", contains(user.getRoles(), "power"));

        users.remove(username);
        assertFalse(assertRoot + "#19", users.containsKey(username));
        user = users.create(username, password, "power");
        assertTrue(assertRoot + "#21", users.containsKey(username));
        assertEquals(assertRoot + "#22", username, user.getName());
        assertEquals(assertRoot + "#23", 1, user.getRoles().length);
        assertTrue(assertRoot + "#24", contains(user.getRoles(), "power"));

        users.remove(username);
        assertFalse(assertRoot + "#25", users.containsKey(username));
        user = users.create(
            username, password, new String[] { "power", "user"
void testJobs()